2018-06-15 23:03:24 +08:00
|
|
|
import { mapRoutes } from "discourse/mapping-router";
|
|
|
|
import Theme from "admin/models/theme";
|
2017-05-31 23:18:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
moduleFor("controller:admin-customize-themes", {
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2018-06-15 23:03:24 +08:00
|
|
|
this.registry.register("router:main", mapRoutes());
|
2017-05-31 23:18:09 +08:00
|
|
|
},
|
2018-06-15 23:03:24 +08:00
|
|
|
needs: ["controller:adminUser"]
|
2017-05-31 23:18:09 +08:00
|
|
|
});
|
|
|
|
|
2018-08-24 09:30:00 +08:00
|
|
|
QUnit.test("can list themes correctly", function(assert) {
|
2018-06-15 23:03:24 +08:00
|
|
|
const defaultTheme = Theme.create({ id: 2, default: true, name: "default" });
|
|
|
|
const userTheme = Theme.create({
|
|
|
|
id: 3,
|
|
|
|
user_selectable: true,
|
|
|
|
name: "name"
|
|
|
|
});
|
|
|
|
const strayTheme1 = Theme.create({ id: 4, name: "stray1" });
|
|
|
|
const strayTheme2 = Theme.create({ id: 5, name: "stray2" });
|
2018-08-24 09:30:00 +08:00
|
|
|
const componentTheme = Theme.create({
|
|
|
|
id: 6,
|
|
|
|
name: "component",
|
|
|
|
component: true
|
|
|
|
});
|
2017-05-31 23:18:09 +08:00
|
|
|
|
|
|
|
const controller = this.subject({
|
2018-08-24 09:30:00 +08:00
|
|
|
model: [strayTheme2, strayTheme1, userTheme, defaultTheme, componentTheme]
|
2017-05-31 23:18:09 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.deepEqual(
|
2018-08-24 09:30:00 +08:00
|
|
|
controller.get("fullThemes").map(t => t.get("name")),
|
2018-08-31 03:23:15 +08:00
|
|
|
[strayTheme2, strayTheme1, userTheme, defaultTheme].map(t => t.get("name")),
|
|
|
|
"returns a list of themes without components"
|
2018-06-15 23:03:24 +08:00
|
|
|
);
|
2018-08-24 09:30:00 +08:00
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
controller.get("childThemes").map(t => t.get("name")),
|
|
|
|
[componentTheme].map(t => t.get("name")),
|
|
|
|
"separate components from themes"
|
|
|
|
);
|
2017-05-31 23:18:09 +08:00
|
|
|
});
|