DEV: Added qunit test functions and did minor refactoring

135191d1d1
This commit is contained in:
Vinoth Kannan
2019-03-13 18:38:27 +05:30
parent d32557ea32
commit c773f82ba1
3 changed files with 40 additions and 5 deletions

View File

@ -14,9 +14,7 @@ export default Ember.ArrayProxy.extend({
renderIconIf("archived", "lock", "archived");
}
this.forEach(args => {
renderIconIf(...args);
});
this.forEach(args => renderIconIf(...args));
}
}).create({
content: [

View File

@ -14,8 +14,8 @@ export default createWidget("topic-status", {
const result = [];
TopicStatusIcons.render(topic, function(name, key) {
const iconArgs = key === "unpinned" ? { class: "unpinned" } : null,
icon = iconNode(name, iconArgs);
const iconArgs = key === "unpinned" ? { class: "unpinned" } : null;
const icon = iconNode(name, iconArgs);
const attributes = {
title: escapeExpression(I18n.t(`topic_statuses.${key}.help`))

View File

@ -0,0 +1,37 @@
import { moduleForWidget, widgetTest } from "helpers/widget-test";
import TopicStatusIcons from "discourse/helpers/topic-status-icons";
moduleForWidget("topic-status");
widgetTest("basics", {
template: '{{mount-widget widget="topic-status" args=args}}',
beforeEach(store) {
this.set("args", {
topic: store.createRecord("topic", { closed: true }),
disableActions: true
});
},
test(assert) {
assert.ok(find(".topic-status .d-icon-lock").length);
}
});
widgetTest("extendability", {
template: '{{mount-widget widget="topic-status" args=args}}',
beforeEach(store) {
TopicStatusIcons.addObject([
"has_accepted_answer",
"check-square-o",
"solved"
]);
this.set("args", {
topic: store.createRecord("topic", {
has_accepted_answer: true
}),
disableActions: true
});
},
test(assert) {
assert.ok(find(".topic-status .d-icon-check-square-o").length);
}
});