mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
lint files
This commit is contained in:
@ -77,7 +77,9 @@ export default Ember.Controller.extend(ModalFunctionality, Ember.Evented, {
|
|||||||
|
|
||||||
if (!category.get("parent_category_id")) {
|
if (!category.get("parent_category_id")) {
|
||||||
category.set("position", position++);
|
category.set("position", position++);
|
||||||
(subcategories[category.get("id")] || []).forEach(subcategory => subcategory.set("position", position++));
|
(subcategories[category.get("id")] || []).forEach(subcategory =>
|
||||||
|
subcategory.set("position", position++)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,11 @@ QUnit.test("fixIndices set unique position number", function(assert) {
|
|||||||
|
|
||||||
reorderCategoriesController.fixIndices();
|
reorderCategoriesController.fixIndices();
|
||||||
|
|
||||||
reorderCategoriesController.get("categoriesOrdered").forEach((category, index) => {
|
reorderCategoriesController
|
||||||
assert.equal(category.get("position"), index);
|
.get("categoriesOrdered")
|
||||||
});
|
.forEach((category, index) => {
|
||||||
|
assert.equal(category.get("position"), index);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test(
|
QUnit.test(
|
||||||
@ -31,10 +33,28 @@ QUnit.test(
|
|||||||
function(assert) {
|
function(assert) {
|
||||||
const store = createStore();
|
const store = createStore();
|
||||||
|
|
||||||
const parent = store.createRecord("category", { id: 1, position: 1, slug: "parent" });
|
const parent = store.createRecord("category", {
|
||||||
const child1 = store.createRecord("category", { id: 2, position: 3, slug: "child1", parent_category_id: 1 });
|
id: 1,
|
||||||
const child2 = store.createRecord("category", { id: 3, position: 0, slug: "child2", parent_category_id: 1 });
|
position: 1,
|
||||||
const other = store.createRecord("category", { id: 4, position: 2, slug: "other" });
|
slug: "parent"
|
||||||
|
});
|
||||||
|
const child1 = store.createRecord("category", {
|
||||||
|
id: 2,
|
||||||
|
position: 3,
|
||||||
|
slug: "child1",
|
||||||
|
parent_category_id: 1
|
||||||
|
});
|
||||||
|
const child2 = store.createRecord("category", {
|
||||||
|
id: 3,
|
||||||
|
position: 0,
|
||||||
|
slug: "child2",
|
||||||
|
parent_category_id: 1
|
||||||
|
});
|
||||||
|
const other = store.createRecord("category", {
|
||||||
|
id: 4,
|
||||||
|
position: 2,
|
||||||
|
slug: "other"
|
||||||
|
});
|
||||||
|
|
||||||
const categories = [child2, parent, other, child1];
|
const categories = [child2, parent, other, child1];
|
||||||
const expectedOrderSlugs = ["parent", "child2", "child1", "other"];
|
const expectedOrderSlugs = ["parent", "child2", "child1", "other"];
|
||||||
@ -44,7 +64,9 @@ QUnit.test(
|
|||||||
|
|
||||||
reorderCategoriesController.fixIndices();
|
reorderCategoriesController.fixIndices();
|
||||||
|
|
||||||
assert.deepEqual(reorderCategoriesController.get("categoriesOrdered").mapBy("slug"), expectedOrderSlugs);
|
assert.deepEqual(
|
||||||
|
reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
|
||||||
|
expectedOrderSlugs
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user