-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #652 split into smaller functions
- Loading branch information
Cuong Vu
committed
Mar 30, 2020
1 parent
104b7cd
commit db2f956
Showing
7 changed files
with
139 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { | |
changedCellsGenerate, | ||
validatedDataGenerate, | ||
calculateNumberOfInvalidRows, | ||
createDataWithInvalidRowsRemoved, | ||
} from '../utils' | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
@@ -166,3 +167,86 @@ describe('calculateNumberOfInvalidRows', () => { | |
expect(result).toBe(2) | ||
}) | ||
}) | ||
describe('calculateNumberOfInvalidRows', () => { | ||
it('should return correctly', () => { | ||
const data = [ | ||
[ | ||
{ value: 'Office name' }, | ||
{ value: 'Building Name' }, | ||
{ value: 'Building No.' }, | ||
{ value: 'Address 1' }, | ||
{ value: 'Address 2' }, | ||
{ value: 'Address 3' }, | ||
{ value: 'Address 4' }, | ||
{ value: 'Post Code' }, | ||
{ value: 'Telephone' }, | ||
{ value: 'Fax' }, | ||
{ value: 'Email' }, | ||
], | ||
[ | ||
{ value: 'London' }, | ||
{ value: 'The White House' }, | ||
{ value: '15' }, | ||
{ value: 'London 1' }, | ||
{ value: '' }, | ||
{ value: 'Londom 3' }, | ||
{ value: '' }, | ||
{ value: 'EC12NH' }, | ||
{ value: '0845 0000' }, | ||
{ value: '' }, | ||
{ value: '[email protected]' }, | ||
], | ||
[ | ||
{ value: 'London2' }, | ||
{ value: 'The Black House' }, | ||
{ value: '11' }, | ||
{ value: 'Test Addres' }, | ||
{ value: '' }, | ||
{ value: 'Adress 3' }, | ||
{ value: '' }, | ||
{ value: 'EC12NH' }, | ||
{ value: '087 471 929' }, | ||
{ value: '' }, | ||
{ value: '[email protected]' }, | ||
], | ||
] | ||
const validateMatrix = [ | ||
[true, true, true, true, true, true, true, true, true, true, false], | ||
[true, true, true, true, true, true, true, true, true, true, true], | ||
[true, true, true, true, true, true, true, true, true, true, true], | ||
] | ||
const result = createDataWithInvalidRowsRemoved(data, validateMatrix) | ||
const expectedResult = { | ||
dataWithInvalidRowsRemoved: [ | ||
[ | ||
{ value: 'London', isValidated: true }, | ||
{ value: 'The White House', isValidated: true }, | ||
{ value: '15', isValidated: true }, | ||
{ value: 'London 1', isValidated: true }, | ||
{ value: '', isValidated: true }, | ||
{ value: 'Londom 3', isValidated: true }, | ||
{ value: '', isValidated: true }, | ||
{ value: 'EC12NH', isValidated: true }, | ||
{ value: '0845 0000', isValidated: true }, | ||
{ value: '', isValidated: true }, | ||
{ value: '[email protected]', isValidated: true }, | ||
], | ||
[ | ||
{ value: 'London2', isValidated: true }, | ||
{ value: 'The Black House', isValidated: true }, | ||
{ value: '11', isValidated: true }, | ||
{ value: 'Test Addres', isValidated: true }, | ||
{ value: '', isValidated: true }, | ||
{ value: 'Adress 3', isValidated: true }, | ||
{ value: '', isValidated: true }, | ||
{ value: 'EC12NH', isValidated: true }, | ||
{ value: '087 471 929', isValidated: true }, | ||
{ value: '', isValidated: true }, | ||
{ value: '[email protected]', isValidated: true }, | ||
], | ||
], | ||
invalidIndies: [{ row: 0, col: 10, cell: { value: 'Email', isValidated: false } }], | ||
} | ||
expect(result).toEqual(expectedResult) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.