discourse/test/javascripts/admin/components/themes-list-item-test.js.es6
OsamaSayegh ca28548762 feedback (see commit description for details)
* fill blank space when no theme is selected
* animate row's height in themes/components list when selecting, and hide children list
* show warning when you move to a different page and have unsaved changes
* refactor `adminCustomizeThemes.show` controller
* allow collapsing/expanding children lists
* fix a bug when adding components to a theme (changed the way it works slightly)
* a bunch of other minor things
2018-09-17 09:49:53 +10:00

85 lines
2.0 KiB
JavaScript

import componentTest from "helpers/component-test";
import Theme from "admin/models/theme";
moduleForComponent("themes-list-item", { integration: true });
componentTest("default theme", {
template: "{{themes-list-item theme=theme}}",
beforeEach() {
this.set("theme", Theme.create({ name: "Test", default: true }));
},
test(assert) {
assert.expect(1);
assert.equal(this.$(".fa-check").length, 1, "shows default theme icon");
}
});
componentTest("pending updates", {
template: "{{themes-list-item theme=theme}}",
beforeEach() {
this.set(
"theme",
Theme.create({ name: "Test", remote_theme: { commits_behind: 6 } })
);
},
test(assert) {
assert.expect(1);
assert.equal(this.$(".fa-refresh").length, 1, "shows pending update icon");
}
});
componentTest("borken theme", {
template: "{{themes-list-item theme=theme}}",
beforeEach() {
this.set(
"theme",
Theme.create({
name: "Test",
theme_fields: [{ name: "scss", type_id: 1, error: "something" }]
})
);
},
test(assert) {
assert.expect(1);
assert.equal(
this.$(".fa-exclamation-circle").length,
1,
"shows broken theme icon"
);
}
});
const childrenList = [1, 2, 3, 4, 5].map(num =>
Theme.create({ name: `Child ${num}`, component: true })
);
componentTest("with children", {
template: "{{themes-list-item theme=theme}}",
beforeEach() {
this.set(
"theme",
Theme.create({ name: "Test", childThemes: childrenList, default: true })
);
},
test(assert) {
assert.expect(2);
assert.deepEqual(
Array.from(this.$(".component")).map(node => node.innerText.trim()),
childrenList.splice(0, 4).map(theme => theme.get("name")),
"lists the first 4 children"
);
assert.deepEqual(
this.$(".others-count")
.text()
.trim(),
I18n.t("admin.customize.theme.and_x_more", { count: 1 }),
"shows count of remaining children"
);
}
});