2019-06-06 16:47:10 +08:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2017-11-21 18:53:09 +08:00
|
|
|
import componentTest from "helpers/component-test";
|
|
|
|
import Topic from "discourse/models/topic";
|
|
|
|
|
|
|
|
const buildTopic = function() {
|
|
|
|
return Topic.create({
|
|
|
|
id: 1234,
|
|
|
|
title: "Qunit Test Topic",
|
|
|
|
deleted: false,
|
|
|
|
pinned: true
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
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() {
|
|
|
|
this.set("subject", selectKit());
|
|
|
|
}
|
|
|
|
});
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
|
|
componentTest("updating the content refreshes the list", {
|
|
|
|
template: "{{pinned-options value=pinned topic=topic}}",
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.automatically_unpin_topics = false;
|
|
|
|
this.set("topic", buildTopic());
|
2020-02-03 21:22:14 +08:00
|
|
|
this.set("pinned", "pinned");
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
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-02-03 21:22:14 +08:00
|
|
|
// we do it manually as clearPin is an ajax call
|
2018-07-25 02:12:09 +08:00
|
|
|
await this.set("pinned", false);
|
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
|
|
|
}
|
|
|
|
});
|