discourse/test/javascripts/components/select-kit/topic-notifications-button-test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
1.7 KiB
JavaScript
Raw Normal View History

import I18n from "I18n";
import selectKit from "helpers/select-kit-helper";
2017-09-12 07:36:58 +08:00
import componentTest from "helpers/component-test";
import Topic from "discourse/models/topic";
const buildTopic = function(level, archetype = "regular") {
2017-09-12 07:36:58 +08:00
return Topic.create({
id: 4563,
title: "Qunit Test Topic",
details: {
notification_level: level
},
archetype
2017-09-12 07:36:58 +08:00
});
};
2018-06-26 20:31:43 +08:00
const originalTranslation =
I18n.translations.en.js.topic.notifications.tracking_pm.title;
moduleForComponent("select-kit/topic-notifications-button", {
integration: true,
afterEach() {
I18n.translations.en.js.topic.notifications.tracking_pm.title = originalTranslation;
}
});
2017-09-12 07:36:58 +08:00
componentTest("the header has a localized title", {
template:
"{{topic-notifications-button notificationLevel=topic.details.notification_level topic=topic}}",
2017-09-12 07:36:58 +08:00
beforeEach() {
this.set("topic", buildTopic(1));
2017-09-12 07:36:58 +08:00
},
async test(assert) {
assert.equal(
selectKit()
.header()
.label(),
"Normal",
"it has the correct label"
);
2017-09-12 07:36:58 +08:00
await this.set("topic", buildTopic(2));
assert.equal(
selectKit()
.header()
.label(),
"Tracking",
"it correctly changes the label"
);
2017-09-12 07:36:58 +08:00
}
});
componentTest("the header has a localized title", {
template:
"{{topic-notifications-button notificationLevel=topic.details.notification_level topic=topic}}",
beforeEach() {
I18n.translations.en.js.topic.notifications.tracking_pm.title = `${originalTranslation} PM`;
this.set("topic", buildTopic(2, "private_message"));
},
test(assert) {
assert.equal(
selectKit()
.header()
.label(),
`${originalTranslation} PM`,
"it has the correct label for PMs"
);
}
});