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";
|
|
|
|
|
|
|
|
const buildTopic = function() {
|
|
|
|
return Topic.create({
|
|
|
|
id: 1234,
|
|
|
|
title: "Qunit Test Topic",
|
|
|
|
deleted: false,
|
|
|
|
pinned: true
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
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 08:22:14 -05:00
|
|
|
this.set("pinned", "pinned");
|
2017-11-21 05:53:09 -05:00
|
|
|
},
|
|
|
|
|
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-02-03 08:22:14 -05:00
|
|
|
// we do it manually as clearPin is an ajax call
|
2018-07-24 14:12:09 -04:00
|
|
|
await this.set("pinned", false);
|
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
|
|
|
}
|
|
|
|
});
|