2020-05-14 10:04:08 -04:00
|
|
|
import I18n from "I18n";
|
2018-08-30 15:23:15 -04:00
|
|
|
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);
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".d-icon-check").length, 1, "shows default theme icon");
|
2018-08-30 15:23:15 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".d-icon-sync").length, 1, "shows pending update icon");
|
2018-08-30 15:23:15 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-11-26 16:49:57 -05:00
|
|
|
componentTest("broken theme", {
|
2018-08-30 15:23:15 -04:00
|
|
|
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(
|
2019-02-25 10:04:55 -05:00
|
|
|
find(".d-icon-exclamation-circle").length,
|
2018-08-30 15:23:15 -04:00
|
|
|
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",
|
2018-09-06 14:56:00 -04:00
|
|
|
Theme.create({ name: "Test", childThemes: childrenList, default: true })
|
2018-08-30 15:23:15 -04:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
assert.expect(2);
|
|
|
|
assert.deepEqual(
|
2018-11-13 08:57:50 -05:00
|
|
|
find(".components")
|
|
|
|
.text()
|
2019-07-03 04:18:11 -04:00
|
|
|
.trim()
|
|
|
|
.split(",")
|
|
|
|
.map(n => n.trim())
|
|
|
|
.join(","),
|
2018-11-13 08:57:50 -05:00
|
|
|
childrenList
|
|
|
|
.splice(0, 4)
|
|
|
|
.map(theme => theme.get("name"))
|
2019-07-03 04:18:11 -04:00
|
|
|
.join(","),
|
2018-08-30 15:23:15 -04:00
|
|
|
"lists the first 4 children"
|
|
|
|
);
|
|
|
|
assert.deepEqual(
|
2018-11-13 08:57:50 -05:00
|
|
|
find(".others-count")
|
2018-08-30 15:23:15 -04:00
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("admin.customize.theme.and_x_more", { count: 1 }),
|
|
|
|
"shows count of remaining children"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|