From 7fba78c7b35098ed2aef7ab0b4a1fc18237833df Mon Sep 17 00:00:00 2001 From: jpellizzari Date: Thu, 8 Dec 2016 11:08:02 -0800 Subject: [PATCH] Liniting fixes --- .../__tests__/node-details-table-test.js | 45 ++++++++++++++----- .../utils/__tests__/array-utils-test.js | 10 +++-- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/client/app/scripts/components/node-details/__tests__/node-details-table-test.js b/client/app/scripts/components/node-details/__tests__/node-details-table-test.js index 37019ee53..3d769d9fc 100644 --- a/client/app/scripts/components/node-details/__tests__/node-details-table-test.js +++ b/client/app/scripts/components/node-details/__tests__/node-details-table-test.js @@ -7,7 +7,9 @@ import configureStore from '../../../stores/configureStore'; const NodeDetailsTable = require('../node-details-table.js').default; describe('NodeDetailsTable', () => { - let nodes, columns, component; + let nodes; + let columns; + let component; beforeEach(() => { columns = [ @@ -47,18 +49,24 @@ describe('NodeDetailsTable', () => { // Get the index of the column whose values we want to match. const columnIndex = columns.findIndex(column => column.id === columnLabel); // Get all the values rendered in the table. - const values = TestUtils.scryRenderedDOMComponentsWithClass(component, 'node-details-table-node-value').map(d => d.title); - // Since we are interested only in the values that appear in the column `columnIndex`, we drop the rest. - // As `values` are ordered by appearance in the DOM structure (that is, first by row and then by column), - // the indexes we are interested in are of the form columnIndex + n * columns.length, where n >= 0. - // Therefore we take only the values at the index which divided by columns.length gives a reminder columnIndex. - const filteredValues = values.filter((element, index) => index % columns.length === columnIndex); + const values = TestUtils + .scryRenderedDOMComponentsWithClass(component, 'node-details-table-node-value') + .map(d => d.title); + // Since we are interested only in the values that appear in the column `columnIndex`, + // we drop the rest. As `values` are ordered by appearance in the DOM structure + // (that is, first by row and then by column), the indexes we are interested in are of the + // form columnIndex + n * columns.length, where n >= 0. Therefore we take only the values + // at the index which divided by columns.length gives a reminder columnIndex. + const filteredValues = values.filter((element, index) => + index % columns.length === columnIndex + ); // Array comparison expect(filteredValues).toEqual(expectedValues); } function clickColumn(title) { - const node = TestUtils.scryRenderedDOMComponentsWithTag(component, 'td').find(d => d.title === title); + const node = TestUtils.scryRenderedDOMComponentsWithTag(component, 'td') + .find(d => d.title === title); TestUtils.Simulate.click(node); } @@ -75,11 +83,26 @@ describe('NodeDetailsTable', () => { ); - matchColumnValues('kubernetes_ip', ['10.44.253.255', '10.244.253.4', '10.244.253.24', '10.244.253.100']); + matchColumnValues('kubernetes_ip', [ + '10.44.253.255', + '10.244.253.4', + '10.244.253.24', + '10.244.253.100' + ]); clickColumn('IP'); - matchColumnValues('kubernetes_ip', ['10.244.253.100', '10.244.253.24', '10.244.253.4', '10.44.253.255']); + matchColumnValues('kubernetes_ip', [ + '10.244.253.100', + '10.244.253.24', + '10.244.253.4', + '10.44.253.255' + ]); clickColumn('IP'); - matchColumnValues('kubernetes_ip', ['10.44.253.255', '10.244.253.4', '10.244.253.24', '10.244.253.100']); + matchColumnValues('kubernetes_ip', [ + '10.44.253.255', + '10.244.253.4', + '10.244.253.24', + '10.244.253.100' + ]); }); }); diff --git a/client/app/scripts/utils/__tests__/array-utils-test.js b/client/app/scripts/utils/__tests__/array-utils-test.js index 7f8603a84..e3aae076d 100644 --- a/client/app/scripts/utils/__tests__/array-utils-test.js +++ b/client/app/scripts/utils/__tests__/array-utils-test.js @@ -16,9 +16,13 @@ describe('ArrayUtils', () => { expect(f(['A', 'B', 'C', 'D', 'E'], 3)).toEqual(['A', 'C', 'E']); expect(f(['A', 'B', 'C', 'D', 'E'], 2)).toEqual(['A', 'E']); - expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 12)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); - expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 11)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); - expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 10)).toEqual([1, 2, 3, 4, 5, 7, 8, 9, 10, 11]); + expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 12)).toEqual( + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] + ); + expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 11)).toEqual( + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); + expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 10)).toEqual([1, 2, 3, 4, 5, 7, 8, 9, 10, 11] + ); expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 9)).toEqual([1, 2, 3, 5, 6, 7, 9, 10, 11]); expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 8)).toEqual([1, 2, 4, 5, 7, 8, 10, 11]); expect(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 7)).toEqual([1, 2, 4, 6, 8, 10, 11]);