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