mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
uses select-box for pinned-button
This commit also moves more logic in dropdown-select-box instead of duplicating it for notifications-options and pinned-options
This commit is contained in:
44
test/javascripts/components/pinned-button-test.js.es6
Normal file
44
test/javascripts/components/pinned-button-test.js.es6
Normal file
@ -0,0 +1,44 @@
|
||||
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
|
||||
});
|
||||
};
|
||||
|
||||
moduleForComponent('pinned-button', { integration: true });
|
||||
|
||||
componentTest('updating the content refreshes the list', {
|
||||
template: '{{pinned-button topic=topic}}',
|
||||
|
||||
beforeEach() {
|
||||
this.siteSettings.automatically_unpin_topics = false;
|
||||
this.set("topic", buildTopic());
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
andThen(() => {
|
||||
assert.equal(find(".pinned-button").hasClass("is-hidden"), false);
|
||||
});
|
||||
|
||||
click(".select-box-header");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(find(".select-box-row.is-selected .title").html().trim(), "Pinned");
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
this.set("topic.pinned", false);
|
||||
assert.equal(find(".select-box-row.is-selected .title").html().trim(), "Unpinned");
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
this.set("topic.deleted", true);
|
||||
assert.equal(find(".pinned-button").hasClass("is-hidden"), true);
|
||||
});
|
||||
}
|
||||
});
|
@ -129,6 +129,7 @@ export default function() {
|
||||
this.get("/t/28830.json", () => response(fixturesByUrl['/t/28830/1.json']));
|
||||
this.get("/t/9.json", () => response(fixturesByUrl['/t/9/1.json']));
|
||||
this.get("/t/12.json", () => response(fixturesByUrl['/t/12/1.json']));
|
||||
this.put("/t/1234/re-pin", success);
|
||||
|
||||
this.get("/t/id_for/:slug", () => {
|
||||
return response({id: 280, slug: "internationalization-localization", url: "/t/internationalization-localization/280"});
|
||||
@ -400,4 +401,4 @@ export default function() {
|
||||
|
||||
server.checkPassthrough = request => request.requestHeaders['Discourse-Script'];
|
||||
return server;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user