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