2019-06-06 04:47:10 -04:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2017-11-21 05:53:09 -05:00
|
|
|
import componentTest from "helpers/component-test";
|
|
|
|
import Topic from "discourse/models/topic";
|
|
|
|
|
2020-03-10 04:56:55 -04:00
|
|
|
const buildTopic = function(pinned = true) {
|
2017-11-21 05:53:09 -05:00
|
|
|
return Topic.create({
|
|
|
|
id: 1234,
|
|
|
|
title: "Qunit Test Topic",
|
|
|
|
deleted: false,
|
2020-03-10 04:56:55 -04:00
|
|
|
pinned
|
2017-11-21 05:53:09 -05:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-02-03 08:22:14 -05:00
|
|
|
moduleForComponent("select-kit/pinned-options", {
|
2017-12-22 07:08:12 -05:00
|
|
|
integration: true,
|
|
|
|
beforeEach: function() {
|
|
|
|
this.set("subject", selectKit());
|
|
|
|
}
|
|
|
|
});
|
2017-11-21 05:53:09 -05:00
|
|
|
|
2020-03-10 04:56:55 -04:00
|
|
|
componentTest("unpinning", {
|
|
|
|
template: "{{pinned-options value=topic.pinned topic=topic}}",
|
2017-11-21 05:53:09 -05:00
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.automatically_unpin_topics = false;
|
|
|
|
this.set("topic", buildTopic());
|
|
|
|
},
|
|
|
|
|
2018-07-24 14:12:09 -04:00
|
|
|
async test(assert) {
|
2019-05-27 04:42:53 -04:00
|
|
|
assert.equal(this.subject.header().name(), "pinned");
|
2017-11-21 05:53:09 -05:00
|
|
|
|
2020-03-10 04:56:55 -04:00
|
|
|
await this.subject.expand();
|
|
|
|
await this.subject.selectRowByValue("unpinned");
|
2017-11-21 05:53:09 -05:00
|
|
|
|
2019-05-27 04:42:53 -04:00
|
|
|
assert.equal(this.subject.header().name(), "unpinned");
|
2017-11-21 05:53:09 -05:00
|
|
|
}
|
|
|
|
});
|
2020-03-10 04:56:55 -04:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
});
|