diff --git a/packages/oui-action-menu/src/index.spec.js b/packages/oui-action-menu/src/index.spec.js index f6dc1f13..c91e1f0d 100644 --- a/packages/oui-action-menu/src/index.spec.js +++ b/packages/oui-action-menu/src/index.spec.js @@ -25,11 +25,9 @@ describe("ouiActionMenu", () => { const element = TestUtils.compileTemplate( ` Action 1 - `, - { + `, { clickHandler: clickSpy - } - ); + }); const buttonElement = element[0].querySelector("button"); expect(buttonElement).toBeTruthy(); diff --git a/packages/oui-checkbox/src/index.spec.js b/packages/oui-checkbox/src/index.spec.js index 3f443ede..98d9b4d1 100644 --- a/packages/oui-checkbox/src/index.spec.js +++ b/packages/oui-checkbox/src/index.spec.js @@ -219,8 +219,8 @@ describe("ouiCheckbox", () => { const element = TestUtils.compileTemplate(` `, { - isRequired: true - }); + isRequired: true + }); const checkboxElement = getCheckboxInputElement(element); expect(angular.element(checkboxElement).prop("required")).toBe(true); @@ -230,8 +230,8 @@ describe("ouiCheckbox", () => { const element = TestUtils.compileTemplate(` `, { - isRequired: false - }); + isRequired: false + }); const checkboxElement = getCheckboxInputElement(element); expect(angular.element(checkboxElement).prop("required")).toBe(false); @@ -242,8 +242,8 @@ describe("ouiCheckbox", () => { `, { - isRequired: true - }); + isRequired: true + }); const form = element.scope().form; const checkboxElement = getCheckboxInputElement(element); diff --git a/packages/oui-criteria-adder/src/index.spec.js b/packages/oui-criteria-adder/src/index.spec.js index 6c504fb9..ad693d49 100644 --- a/packages/oui-criteria-adder/src/index.spec.js +++ b/packages/oui-criteria-adder/src/index.spec.js @@ -73,13 +73,14 @@ describe("ouiCriteriaAdder", () => { const submitButton = component[0].querySelectorAll("[type=submit]"); const dropdown = component.find("oui-dropdown"); const fields = component.find("oui-field"); + const expectedLength = 3; expect(form.length).toBe(1); expect(triggerButton.length).toBe(1); expect(submitButton.length).toBe(1); expect(angular.element(triggerButton).attr("oui-dropdown-trigger")).toBeDefined(); expect(dropdown.length).toBe(1); - expect(fields.length).toBe(3); + expect(fields.length).toBe(expectedLength); }); it("should have an attribute id and name on the form and every inputs/selectors, and removed on the root component", () => { diff --git a/packages/oui-criteria-container/src/index.spec.js b/packages/oui-criteria-container/src/index.spec.js index b1f7bf1a..887fa7ef 100644 --- a/packages/oui-criteria-container/src/index.spec.js +++ b/packages/oui-criteria-container/src/index.spec.js @@ -66,7 +66,8 @@ describe("ouiCriteriaContainer", () => { it("should delete a criteria", () => { controller.criteria.push(criterion); controller.criteria.push(criterion2); - expect(controller.criteria.length).toEqual(2); + const expectedLength = 2; + expect(controller.criteria.length).toEqual(expectedLength); controller.remove(criterion); expect(controller.criteria.length).toEqual(1); @@ -87,13 +88,15 @@ describe("ouiCriteriaContainer", () => { expect(controller.criteria.length).toEqual(0); controller.set(criteria); - expect(controller.criteria.length).toEqual(2); + const expectedLength = 2; + expect(controller.criteria.length).toEqual(expectedLength); }); it("should delete all criteria", () => { controller.criteria.push(criterion); controller.criteria.push(criterion2); - expect(controller.criteria.length).toEqual(2); + const expectedLength = 2; + expect(controller.criteria.length).toEqual(expectedLength); controller.clear(); expect(controller.criteria.length).toEqual(0); diff --git a/packages/oui-datagrid/src/filter/filter.spec.js b/packages/oui-datagrid/src/filter/filter.spec.js index b049b6cc..5126ed53 100644 --- a/packages/oui-datagrid/src/filter/filter.spec.js +++ b/packages/oui-datagrid/src/filter/filter.spec.js @@ -83,7 +83,8 @@ describe("Filter", () => { it("should apply 1 filter", () => { filter = new Filter([textSearchCriterion], columns); const filtered = filter.applyFilter(fakeData); - expect(filtered.length).toBe(2); + const expectedLength = 2; + expect(filtered.length).toBe(expectedLength); }); }); @@ -92,7 +93,8 @@ describe("Filter", () => { it("should find text in object", () => { filter = new Filter([textSearchCriterion], columns); const filtered = filter.applyCriteria(fakeData, textSearchCriterion); - expect(filtered.length).toBe(2); + const expectedLength = 2; + expect(filtered.length).toBe(expectedLength); }); }); @@ -106,7 +108,8 @@ describe("Filter", () => { operator: "contains", value: "aaron" }); - expect(filtered.length).toBe(2); + const expectedLength = 2; + expect(filtered.length).toBe(expectedLength); }); it("should filter (negated)", () => { @@ -117,7 +120,8 @@ describe("Filter", () => { operator: "containsNot", value: "aaron" }); - expect(filtered.length).toBe(fakeData.length - 2); + const expectedLength = 2; + expect(filtered.length).toBe(fakeData.length - expectedLength); }); }); diff --git a/packages/oui-datagrid/src/parameters/datagrid-parameters.spec.js b/packages/oui-datagrid/src/parameters/datagrid-parameters.spec.js index b9d725c7..6cca86a7 100644 --- a/packages/oui-datagrid/src/parameters/datagrid-parameters.spec.js +++ b/packages/oui-datagrid/src/parameters/datagrid-parameters.spec.js @@ -66,7 +66,7 @@ describe("ouiDatagridParameters", () => { it("should display a disabled checkbox column when customization is prevented", () => { const columnsElements = getColumns(element); - const disabledColumn = getCheckbox(columnsElements, 3); + const disabledColumn = getCheckbox(columnsElements, 3); // eslint-disable-line no-magic-numbers expect(disabledColumn.prop("disabled")).toBe(true); }); }); @@ -91,7 +91,7 @@ describe("ouiDatagridParameters", () => { const columnsElements = getColumns(element); const $checkbox1 = getCheckbox(columnsElements, 0); const $checkbox2 = getCheckbox(columnsElements, 1); - const $checkbox3 = getCheckbox(columnsElements, 2); + const $checkbox3 = getCheckbox(columnsElements, 2); // eslint-disable-line no-magic-numbers const expected = angular.copy(columns); expected[0].hidden = true; diff --git a/packages/oui-dropdown/src/index.spec.js b/packages/oui-dropdown/src/index.spec.js index ac00cddc..f2fa14d1 100644 --- a/packages/oui-dropdown/src/index.spec.js +++ b/packages/oui-dropdown/src/index.spec.js @@ -190,8 +190,9 @@ describe("ouiDropdown", () => { `); const links = element.find("oui-dropdown-item").find("a"); + const expectedLength = 2; - expect(links.length).toBe(2); + expect(links.length).toBe(expectedLength); expect(links.hasClass("oui-dropdown-option")).toBeTruthy(); }); diff --git a/packages/oui-field/src/index.spec.js b/packages/oui-field/src/index.spec.js index 97c58652..ee391b5e 100644 --- a/packages/oui-field/src/index.spec.js +++ b/packages/oui-field/src/index.spec.js @@ -425,6 +425,7 @@ describe("ouiField", () => { describe("with radio buttons", () => { it("should detect all the radio buttons", () => { const name = "protocol"; + const expectedLength = 3; const element = TestUtils.compileTemplate(` @@ -454,7 +455,7 @@ describe("ouiField", () => { const controller = element.controller("ouiField"); // There is 3 HTML elements with the same name - expect(controller.controls[name].length).toEqual(3); + expect(controller.controls[name].length).toEqual(expectedLength); }); }); diff --git a/packages/oui-form-actions/src/index.spec.js b/packages/oui-form-actions/src/index.spec.js index e16ad21f..1336f894 100644 --- a/packages/oui-form-actions/src/index.spec.js +++ b/packages/oui-form-actions/src/index.spec.js @@ -114,8 +114,8 @@ describe("ouiFormActions", () => { on-submit="$ctrl.onSubmitTest()" on-cancel="$ctrl.onCancelTest()"> `, { - onSubmitTest: jasmine.createSpy("onSubmit") - }); + onSubmitTest: jasmine.createSpy("onSubmit") + }); component.find("button").eq(0).triggerHandler("click"); expect(component.scope().$ctrl.onSubmitTest).toHaveBeenCalled(); @@ -127,8 +127,8 @@ describe("ouiFormActions", () => { on-submit="$ctrl.onSubmitTest()" on-cancel="$ctrl.onCancelTest()"> `, { - onCancelTest: jasmine.createSpy("onCancel") - }); + onCancelTest: jasmine.createSpy("onCancel") + }); component.find("button").eq(1).triggerHandler("click"); expect(component.scope().$ctrl.onCancelTest).toHaveBeenCalled(); diff --git a/packages/oui-navbar/src/index.spec.js b/packages/oui-navbar/src/index.spec.js index c3e67f15..3635153b 100644 --- a/packages/oui-navbar/src/index.spec.js +++ b/packages/oui-navbar/src/index.spec.js @@ -52,12 +52,12 @@ describe("ouiNavbar", () => { aside-links="$ctrl.asideLinks" toggler-links="$ctrl.togglerLinks"> `, { - brand: mockData.brand, - activeLink: mockData.mainLinks[0].name, - mainLinks: mockData.mainLinks, - asideLinks: mockData.asideLinks, - togglerLinks: mockData.togglerLinks - }); + brand: mockData.brand, + activeLink: mockData.mainLinks[0].name, + mainLinks: mockData.mainLinks, + asideLinks: mockData.asideLinks, + togglerLinks: mockData.togglerLinks + }); const controller = component.controller("ouiNavbar"); $timeout.flush(); @@ -238,8 +238,8 @@ describe("ouiNavbar", () => { icon-class="{{$ctrl.brand.iconClass}}"> `, { - brand: data - }); + brand: data + }); controller = component.find("oui-navbar-brand").controller("ouiNavbarBrand"); $timeout.flush(); @@ -287,13 +287,13 @@ describe("ouiNavbar", () => { `, { - name: "foo", - title: "bar", - label: "lorem", - badge: 5, - icon: "oui-icon oui-icon-help_circle", - text: "Lorem ipsum" - }); + name: "foo", + title: "bar", + label: "lorem", + badge: 5, + icon: "oui-icon oui-icon-help_circle", + text: "Lorem ipsum" + }); $timeout.flush(); }); @@ -332,13 +332,13 @@ describe("ouiNavbar", () => { `, { - name: "foo", - title: "bar", - label: "lorem", - badge: 5, - icon: "oui-icon oui-icon-help_circle", - text: "Lorem ipsum" - }); + name: "foo", + title: "bar", + label: "lorem", + badge: 5, + icon: "oui-icon oui-icon-help_circle", + text: "Lorem ipsum" + }); const dropdownMenu = component.find("oui-navbar-dropdown-menu"); $timeout.flush(); @@ -367,11 +367,11 @@ describe("ouiNavbar", () => { `, { - name: data.name, - title: data.title, - headerTitle: data.headerTitle, - subLinks: data.subLinks - }); + name: data.name, + title: data.title, + headerTitle: data.headerTitle, + subLinks: data.subLinks + }); $timeout.flush(); @@ -403,11 +403,11 @@ describe("ouiNavbar", () => { `, { - name: data.name, - title: data.title, - headerTitle: data.headerTitle, - subLinks: data.subLinks - }); + name: data.name, + title: data.title, + headerTitle: data.headerTitle, + subLinks: data.subLinks + }); $timeout.flush(); @@ -430,11 +430,11 @@ describe("ouiNavbar", () => { `, { - name: data.name, - title: data.title, - headerTitle: data.headerTitle, - subLinks: data.subLinks - }); + name: data.name, + title: data.title, + headerTitle: data.headerTitle, + subLinks: data.subLinks + }); $timeout.flush(); diff --git a/packages/oui-numeric/src/index.spec.js b/packages/oui-numeric/src/index.spec.js index ad8276a9..b4ce7ff0 100644 --- a/packages/oui-numeric/src/index.spec.js +++ b/packages/oui-numeric/src/index.spec.js @@ -17,19 +17,21 @@ describe("ouiNumeric", () => { it("should display an input with two buttons", () => { const elt = angular.element(''); const scope = $rootScope.$new(); + const expectedLength = 2; $compile(elt)(scope); scope.$digest(); expect(elt.find("input").length).toBe(1); - expect(elt.find("button").length).toBe(2); + expect(elt.find("button").length).toBe(expectedLength); }); it("should updates model when input changes", () => { const elt = angular.element(''); const scope = $rootScope.$new(); + const value = 5; $compile(elt)(scope); scope.$digest(); elt.find("input").controller("ngModel").$setViewValue("5"); - expect(scope.foo).toBe(5); + expect(scope.foo).toBe(value); elt.find("input").controller("ngModel").$setViewValue("1"); expect(scope.foo).toBe(1); }); @@ -49,36 +51,40 @@ describe("ouiNumeric", () => { it("should not updates model when input is given invalid value", () => { const elt = angular.element(''); const scope = $rootScope.$new(); + const value1 = 3; + const value2 = 7; $compile(elt)(scope); scope.$digest(); elt.find("input").controller("ngModel").$setViewValue("1"); expect(scope.foo).toBe(1); elt.find("input").controller("ngModel").$setViewValue("hello"); expect(scope.foo).toBe(1); - elt.find("input").controller("ngModel").$setViewValue(3); - expect(scope.foo).toBe(3); - elt.find("input").controller("ngModel").$setViewValue(7); - expect(scope.foo).toBe(3); + elt.find("input").controller("ngModel").$setViewValue(value1); + expect(scope.foo).toBe(value1); + elt.find("input").controller("ngModel").$setViewValue(value2); + expect(scope.foo).toBe(value1); }); it("should decrement value when clicking first button", () => { const elt = angular.element(''); const scope = $rootScope.$new(); + const foo = 10; $compile(elt)(scope); - scope.foo = 10; + scope.foo = foo; scope.$digest(); getDecrementBtn(elt).triggerHandler("click"); - expect(scope.foo).toBe(9); + expect(scope.foo).toBe(foo - 1); }); it("should increment value when clicking second button", () => { const elt = angular.element(''); const scope = $rootScope.$new(); + const foo = 10; $compile(elt)(scope); - scope.foo = 10; + scope.foo = foo; scope.$digest(); getIncrementBtn(elt).triggerHandler("click"); - expect(scope.foo).toBe(11); + expect(scope.foo).toBe(foo + 1); }); it("should disable left button is value is lower or equal to min", () => { @@ -146,7 +152,8 @@ describe("ouiNumeric", () => { $compile(elt)(scope); scope.$digest(); elt.find("input").controller("ngModel").$setViewValue("10"); - expect(scope.onChange).toHaveBeenCalledWith(10); + const value = 10; + expect(scope.onChange).toHaveBeenCalledWith(value); }); it("should not trigger onChange callback when value is updated with no changes", () => { diff --git a/packages/oui-pagination/src/index.spec.js b/packages/oui-pagination/src/index.spec.js index e1afc659..e222c276 100644 --- a/packages/oui-pagination/src/index.spec.js +++ b/packages/oui-pagination/src/index.spec.js @@ -2,7 +2,7 @@ describe("ouiPagination", () => { let TestUtils; const customPageSize = 50; - const customPageSizesList = [25, 50, 100, 200]; + const customPageSizesList = [25, 50, 100, 200]; // eslint-disable-line no-magic-numbers const getPagination = elt => elt[0].querySelector(".oui-pagination"); const getProgress = elt => elt[0].querySelector(".oui-pagination__progress"); @@ -70,9 +70,10 @@ describe("ouiPagination", () => { total-items="100"> `); + const pageSize = 50; const paginationController = element.controller("ouiPagination"); - expect(paginationController.pageSize).toEqual(50); + expect(paginationController.pageSize).toEqual(pageSize); }); it("should display 4 buttons for page selection", () => { @@ -83,8 +84,9 @@ describe("ouiPagination", () => { total-items="100"> `); + const expectedLength = 4; - expect(getSelector(element).querySelectorAll(".oui-button-group .oui-button").length).toEqual(4); + expect(getSelector(element).querySelectorAll(".oui-button-group .oui-button").length).toEqual(expectedLength); expect(getSelector(element).querySelector(".oui-pagination-menu")).toBeNull(); }); @@ -138,8 +140,8 @@ describe("ouiPagination", () => { on-change="$ctrl.clickHandler($event)"> `, { - clickHandler: clickSpy - }); + clickHandler: clickSpy + }); angular.element(getNextButton(element)).triggerHandler("click"); expect(clickSpy).toHaveBeenCalledWith({ @@ -159,8 +161,8 @@ describe("ouiPagination", () => { on-change="$ctrl.clickHandler($event)"> `, { - clickHandler: clickSpy - }); + clickHandler: clickSpy + }); angular.element(getPreviousButton(element)).triggerHandler("click"); expect(clickSpy).toHaveBeenCalledWith({ @@ -204,7 +206,8 @@ describe("ouiPagination", () => { expect(buttons[1].hasAttribute("disabled")).toBeTruthy(); clickSpy.calls.reset(); - angular.element(buttons[3]).triggerHandler("click"); + const index = 3; + angular.element(buttons[index]).triggerHandler("click"); expect(clickSpy).toHaveBeenCalledWith({ offset: 76, pageSize: 25 @@ -243,7 +246,9 @@ describe("ouiPagination", () => { expect(buttons[1].hasAttribute("disabled")).toBeTruthy(); clickSpy.calls.reset(); - angular.element(buttons[39]).triggerHandler("click"); + + const index = 39; + angular.element(buttons[index]).triggerHandler("click"); expect(clickSpy).toHaveBeenCalledWith(jasmine.objectContaining({ offset: 976 })); expect(clickSpy.calls.count()).toEqual(1); }); @@ -260,7 +265,8 @@ describe("ouiPagination", () => { `); const buttons = getProgress(element).querySelectorAll(".oui-pagination-menu__items-list .oui-pagination-menu__item"); - expect(buttons.length).toEqual(4); + const expectedLength = 4; + expect(buttons.length).toEqual(expectedLength); expect(buttons[0].hasAttribute("disabled")).toBeTruthy(); }); @@ -292,7 +298,8 @@ describe("ouiPagination", () => { // Count page buttons const pageButtons = getSelector(element).querySelectorAll(".oui-pagination-menu__items-list .oui-pagination-menu__item"); - expect(pageButtons.length).toEqual(20); + const length = 20; + expect(pageButtons.length).toEqual(length); }); it("should reset offset to 1 when page size is changed", () => { @@ -331,7 +338,8 @@ describe("ouiPagination", () => { // So, instead of displaying 4 values (see customPageSizesList = [25, 50, 100, 200]) the page size list // is limited to all values lower or equal to pageSizeMax: [25, 50] (length: 2). const pageSizesButtons = getProgress(element).querySelectorAll(".oui-pagination-menu__items-list .oui-pagination-menu__item"); - expect(pageSizesButtons.length).toEqual(2); + const expectedLength = 2; + expect(pageSizesButtons.length).toEqual(expectedLength); }); it("should have max page size limiting the page size list (and creating a new value in this list)", () => { @@ -343,16 +351,18 @@ describe("ouiPagination", () => { total-items="1000"> `, { - pageSizeMax: 80 - }); + pageSizeMax: 80 + }); // Page sizes list should not list page size above pageSizeMax (80). // So, instead of displaying 4 values (see customPageSizesList = [25, 50, 100, 200]) the page size list // is limited to all values lower or equal to pageSizeMax and pageSizeMax: [25, 50, 80] (length: 3). const pageSizesButtons = getPageSizeButtons(element); + const expectedLength = 3; + const index = 2; - expect(pageSizesButtons.length).toEqual(3); - expect(pageSizesButtons[2].innerHTML).toEqual("80"); + expect(pageSizesButtons.length).toEqual(expectedLength); + expect(pageSizesButtons[index].innerHTML).toEqual("80"); }); it("should be reinitilized", () => { @@ -364,8 +374,8 @@ describe("ouiPagination", () => { total-items="1000"> `, { - pageSizeMax: 80 - }); + pageSizeMax: 80 + }); const contextController = element.scope().$ctrl; let pageSizesButtons = getPageSizeButtons(element); diff --git a/packages/oui-progress/src/index.spec.js b/packages/oui-progress/src/index.spec.js index 77f6223f..daa0dabd 100644 --- a/packages/oui-progress/src/index.spec.js +++ b/packages/oui-progress/src/index.spec.js @@ -102,7 +102,7 @@ describe("ouiProgress", () => { it("should have the correct width when max-value is used", () => { const value = 10; - const expectedWidth = value / 2; + const expectedWidth = value / 2; // eslint-disable-line no-magic-numbers const element = TestUtils.compileTemplate(` @@ -145,7 +145,7 @@ describe("ouiProgress", () => { it("should have the correct position according to value", () => { const value = 10; const maxValue = 200; - const leftPosition = value / (maxValue / 100); + const leftPosition = value / (maxValue / 100); // eslint-disable-line no-magic-numbers const element = TestUtils.compileTemplate(` diff --git a/packages/oui-search/src/index.spec.js b/packages/oui-search/src/index.spec.js index ea10e7f3..1d54b4ff 100644 --- a/packages/oui-search/src/index.spec.js +++ b/packages/oui-search/src/index.spec.js @@ -22,11 +22,12 @@ describe("ouiSearch", () => { const buttons = component.find("button"); const reset = buttons.eq(0); const submit = buttons.eq(1); + const length = 2; expect(form.length).toBe(1); expect(input.length).toBe(1); expect(input.attr("type")).toBe("text"); - expect(buttons.length).toBe(2); + expect(buttons.length).toBe(length); expect(reset.attr("type")).toBe("reset"); expect(submit.attr("type")).toBe("submit"); }); @@ -185,6 +186,7 @@ describe("ouiSearch", () => { `, { onChangeSpy }); + const delay = 850; setTimeout(() => { const input = element.find("input"); @@ -192,7 +194,7 @@ describe("ouiSearch", () => { input.triggerHandler("input"); expect(onChangeSpy).not.toHaveBeenCalled(); done(); - }, 850); + }, delay); }); it("should delete preview criterion if search becomes too short", done => { diff --git a/packages/oui-select-picker/src/index.spec.js b/packages/oui-select-picker/src/index.spec.js index 12a11be5..46e54e5d 100644 --- a/packages/oui-select-picker/src/index.spec.js +++ b/packages/oui-select-picker/src/index.spec.js @@ -146,8 +146,8 @@ describe("ouiSelectPicker", () => { model="$ctrl.selectValue"> `, { - selectValue: "bValue" - }); + selectValue: "bValue" + }); const selectPickerComponent1 = element.children()[0]; const selectPickerComponent2 = element.children()[1]; @@ -175,8 +175,8 @@ describe("ouiSelectPicker", () => { on-change="$ctrl.onChange(modelValue)"> `, { - onChange: onChangeSpy - }); + onChange: onChangeSpy + }); const selectPickerComponent1 = element.children()[0]; const selectPickerComponent2 = element.children()[1]; @@ -212,8 +212,8 @@ describe("ouiSelectPicker", () => { on-change="$ctrl.onChange(modelValue)"> `, { - onChange: onChangeSpy - }); + onChange: onChangeSpy + }); const selectPickerComponent1 = element.children()[0]; const selectPickerComponent2 = element.children()[1]; diff --git a/packages/oui-select/src/index.spec.js b/packages/oui-select/src/index.spec.js index f10e119f..a92a84bd 100644 --- a/packages/oui-select/src/index.spec.js +++ b/packages/oui-select/src/index.spec.js @@ -42,8 +42,8 @@ describe("ouiSelect", () => { data-align="start"> `, { - countries: data - }); + countries: data + }); expect(angular.element(getContainer(element)).attr("title")).toEqual(title); expect(angular.element(getDropdownButton(element)).text()).toContain(placeholder); @@ -62,8 +62,8 @@ describe("ouiSelect", () => { data-align="start"> `, { - countries: data - }); + countries: data + }); const $container = angular.element(getContainer(element)); const $triggerButton = angular.element(getDropdownButton(element)); @@ -93,8 +93,8 @@ describe("ouiSelect", () => { `, { - countries: data - }); + countries: data + }); const $container = angular.element(getContainer(element)); const $triggerButton = angular.element(getDropdownButton(element)); @@ -120,8 +120,8 @@ describe("ouiSelect", () => { data-align="start"> `, { - countries: data - }); + countries: data + }); const $container = angular.element(getContainer(element)); const $triggerButton = angular.element(getDropdownButton(element)); @@ -132,7 +132,7 @@ describe("ouiSelect", () => { $triggerButton.triggerHandler("click"); // Select 5th element and check if it's highlighted. - let $itemButton = angular.element(getDropdownItem(element, 4)); + let $itemButton = angular.element(getDropdownItem(element, 4)); // eslint-disable-line no-magic-numbers expect($itemButton.hasClass(selectedItemClass)).toBeFalsy(); $itemButton.triggerHandler("click"); expect($itemButton.hasClass(selectedItemClass)).toBeTruthy(); @@ -142,7 +142,7 @@ describe("ouiSelect", () => { // Reopen dropdown and check if the selected element is highlighted. // The element is retrieved again to be sure to not test on a detached element. - $itemButton = angular.element(getDropdownItem(element, 4)); + $itemButton = angular.element(getDropdownItem(element, 4)); // eslint-disable-line no-magic-numbers expect($itemButton.hasClass(selectedItemClass)).toBeTruthy(); }); }); @@ -159,8 +159,8 @@ describe("ouiSelect", () => { data-align="start"> `, { - countries: data - }); + countries: data + }); expect(getDropdownItems(element).length).toEqual(data.length); expect(angular.element(getDropdownItem(element, 0)).text()).toContain(data[0].name); @@ -178,8 +178,8 @@ describe("ouiSelect", () => { data-align="start"> `, { - array: stringArray - }); + array: stringArray + }); expect(getDropdownItems(element).length).toEqual(stringArray.length); expect(angular.element(getDropdownItem(element, 0)).text()).toContain(stringArray[0]); @@ -202,9 +202,9 @@ describe("ouiSelect", () => { data-align="start"> `, { - countries: data, - groupByFirstLetter - }); + countries: data, + groupByFirstLetter + }); const groups = uniq(data.map(groupByFirstLetter)); const firstGroupElement = getItemsGroup(element, 0); @@ -230,8 +230,8 @@ describe("ouiSelect", () => { on-blur="$ctrl.onBlur()"> `, { - onBlur - }); + onBlur + }); angular.element(getDropdownButton(element)).triggerHandler("blur"); expect(onBlur).toHaveBeenCalled(); @@ -251,8 +251,8 @@ describe("ouiSelect", () => { on-focus="$ctrl.onFocus()"> `, { - onFocus - }); + onFocus + }); angular.element(getDropdownButton(element)).triggerHandler("focus"); expect(onFocus).toHaveBeenCalled(); @@ -272,19 +272,21 @@ describe("ouiSelect", () => { on-change="$ctrl.onChange(modelValue)"> `, { - countries: data, - onChange - }); + countries: data, + onChange + }); - let $itemButton = angular.element(getDropdownItem(element, 4)); + const index1 = 4; + const index2 = 10; + let $itemButton = angular.element(getDropdownItem(element, index1)); $itemButton.triggerHandler("click"); $timeout.flush(); - expect(onChange).toHaveBeenCalledWith(data[4]); + expect(onChange).toHaveBeenCalledWith(data[index1]); - $itemButton = angular.element(getDropdownItem(element, 10)); + $itemButton = angular.element(getDropdownItem(element, index2)); $itemButton.triggerHandler("click"); $timeout.flush(); - expect(onChange).toHaveBeenCalledWith(data[10]); + expect(onChange).toHaveBeenCalledWith(data[index2]); }); }); }); diff --git a/packages/oui-stepper/src/index.spec.js b/packages/oui-stepper/src/index.spec.js index 4cd8b78b..b3d70a69 100644 --- a/packages/oui-stepper/src/index.spec.js +++ b/packages/oui-stepper/src/index.spec.js @@ -114,9 +114,9 @@ describe("ouiStepper", () => { `, { - onInit, - onFinish - }); + onInit, + onFinish + }); $timeout.flush(); // Initial condition diff --git a/packages/oui-switch/src/index.spec.js b/packages/oui-switch/src/index.spec.js index 85917108..343e3d08 100644 --- a/packages/oui-switch/src/index.spec.js +++ b/packages/oui-switch/src/index.spec.js @@ -154,8 +154,8 @@ describe("ouiSwitch", () => { const element = TestUtils.compileTemplate(` `, { - isRequired: true - }); + isRequired: true + }); $timeout.flush(); const checkboxElement = getSwitchInputElement(element); @@ -166,8 +166,8 @@ describe("ouiSwitch", () => { const element = TestUtils.compileTemplate(` `, { - isRequired: false - }); + isRequired: false + }); $timeout.flush(); const checkboxElement = getSwitchInputElement(element); @@ -179,8 +179,8 @@ describe("ouiSwitch", () => { `, { - isRequired: true - }); + isRequired: true + }); $timeout.flush(); const form = element.scope().form;