We used many global functions to handle tests when they should be imported like other libraries in our application. This also gets us closer to the way Ember CLI prefers our tests to be laid out.
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
import { moduleForComponent } from "ember-qunit";
|
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
|
import componentTest from "discourse/tests/helpers/component-test";
|
|
import Topic from "discourse/models/topic";
|
|
|
|
const buildTopic = function (pinned = true) {
|
|
return Topic.create({
|
|
id: 1234,
|
|
title: "Qunit Test Topic",
|
|
deleted_at: new Date(),
|
|
pinned,
|
|
});
|
|
};
|
|
|
|
moduleForComponent("select-kit/pinned-options", {
|
|
integration: true,
|
|
beforeEach: function () {
|
|
this.set("subject", selectKit());
|
|
},
|
|
});
|
|
|
|
componentTest("unpinning", {
|
|
template: "{{pinned-options value=topic.pinned topic=topic}}",
|
|
|
|
beforeEach() {
|
|
this.siteSettings.automatically_unpin_topics = false;
|
|
this.set("topic", buildTopic());
|
|
},
|
|
|
|
async test(assert) {
|
|
assert.equal(this.subject.header().name(), "pinned");
|
|
|
|
await this.subject.expand();
|
|
await this.subject.selectRowByValue("unpinned");
|
|
|
|
assert.equal(this.subject.header().name(), "unpinned");
|
|
},
|
|
});
|
|
|
|
componentTest("pinning", {
|
|
template: "{{pinned-options value=topic.pinned topic=topic}}",
|
|
|
|
beforeEach() {
|
|
this.siteSettings.automatically_unpin_topics = false;
|
|
this.set("topic", buildTopic(false));
|
|
},
|
|
|
|
async test(assert) {
|
|
assert.equal(this.subject.header().name(), "unpinned");
|
|
|
|
await this.subject.expand();
|
|
await this.subject.selectRowByValue("pinned");
|
|
|
|
assert.equal(this.subject.header().name(), "pinned");
|
|
},
|
|
});
|