diff --git a/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 b/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 index 5f181438dcd..e910b078fc2 100644 --- a/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 +++ b/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 @@ -77,7 +77,9 @@ export default Ember.Controller.extend(ModalFunctionality, Ember.Evented, { if (!category.get("parent_category_id")) { category.set("position", position++); - (subcategories[category.get("id")] || []).forEach(subcategory => subcategory.set("position", position++)); + (subcategories[category.get("id")] || []).forEach(subcategory => + subcategory.set("position", position++) + ); } } diff --git a/test/javascripts/controllers/reorder-categories-test.js.es6 b/test/javascripts/controllers/reorder-categories-test.js.es6 index d7a2fe08fe7..2e03938dc34 100644 --- a/test/javascripts/controllers/reorder-categories-test.js.es6 +++ b/test/javascripts/controllers/reorder-categories-test.js.es6 @@ -21,9 +21,11 @@ QUnit.test("fixIndices set unique position number", function(assert) { reorderCategoriesController.fixIndices(); - reorderCategoriesController.get("categoriesOrdered").forEach((category, index) => { - assert.equal(category.get("position"), index); - }); + reorderCategoriesController + .get("categoriesOrdered") + .forEach((category, index) => { + assert.equal(category.get("position"), index); + }); }); QUnit.test( @@ -31,10 +33,28 @@ QUnit.test( function(assert) { const store = createStore(); - const parent = store.createRecord("category", { id: 1, position: 1, 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 parent = store.createRecord("category", { + id: 1, + position: 1, + 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 expectedOrderSlugs = ["parent", "child2", "child1", "other"]; @@ -44,7 +64,9 @@ QUnit.test( reorderCategoriesController.fixIndices(); - assert.deepEqual(reorderCategoriesController.get("categoriesOrdered").mapBy("slug"), expectedOrderSlugs); + assert.deepEqual( + reorderCategoriesController.get("categoriesOrdered").mapBy("slug"), + expectedOrderSlugs + ); } ); -