Liniting fixes

This commit is contained in:
jpellizzari
2016-12-08 11:08:02 -08:00
parent 38344a2a48
commit 7fba78c7b3
2 changed files with 41 additions and 14 deletions

View File

@@ -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', () => {
</Provider>
);
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'
]);
});
});

View File

@@ -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]);