-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
santiago.trigo
committed
Sep 4, 2024
1 parent
d028335
commit c4ef013
Showing
7 changed files
with
229 additions
and
102 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
83 changes: 83 additions & 0 deletions
83
packages/table/src/helpers/afterRow/addAfterRowsToRowDefs.test.ts
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
|
||
import { TRowDef } from '../../declarations'; | ||
import { | ||
addAfterRowToRowDefs, | ||
getRowDef, | ||
setHideRowDef, | ||
} from './addAfterRowsToRowDefs'; | ||
|
||
describe('Add afterrow to row defs', () => { | ||
describe('getRowDef', () => { | ||
const cases: [string, TRowDef[], string, TRowDef][] = [ | ||
['empty row defs return undefined', [], '1', undefined], | ||
['id null return undefined', [{ id: '1' }], null, undefined], | ||
['rowDef null return undefined', null, '1', undefined], | ||
['return element rowDef', [{ id: '1' }], '1', { id: '1' }], | ||
['id not find in rowDef', [{ id: '1' }], '2', undefined], | ||
]; | ||
|
||
test.each(cases)('%s', (_title, rowDefs, id, expected) => { | ||
expect(getRowDef(rowDefs, id)).toEqual(expected); | ||
}); | ||
}); | ||
|
||
describe('addAfterRowToRowDefs', () => { | ||
const cases: [string, TRowDef[], string, TRowDef[]][] = [ | ||
[ | ||
'add element with rowdefs empty', | ||
[], | ||
'1', | ||
[{ id: `afterRow-1`, hide: false }], | ||
], | ||
[ | ||
'add element with rowdefs > 0', | ||
[{ id: `afterRow-1`, hide: false }], | ||
'2', | ||
[ | ||
{ id: `afterRow-1`, hide: false }, | ||
{ id: `afterRow-2`, hide: false }, | ||
], | ||
], | ||
['add element with rowdefs empty', null, '1', undefined], | ||
]; | ||
|
||
test.each(cases)('%s', (_title, rowDefs, id, expected) => { | ||
expect(addAfterRowToRowDefs(rowDefs, id, () => null, 13)).toMatchObject( | ||
expected, | ||
); | ||
}); | ||
}); | ||
|
||
describe('setHideRowDef', () => { | ||
const cases: [string, TRowDef[], string, boolean, TRowDef[]][] = [ | ||
['empty rowdefs return empty rowdefs', [], '1', true, []], | ||
['rowdefs null return undefined', null, '1', true, undefined], | ||
[ | ||
'changed visible to no visible', | ||
[{ id: `afterRow-1`, hide: false }], | ||
'1', | ||
false, | ||
[{ id: `afterRow-1`, hide: true }], | ||
], | ||
[ | ||
'changed no visible to visible', | ||
[{ id: `afterRow-1`, hide: true }], | ||
'1', | ||
false, | ||
[{ id: `afterRow-1`, hide: true }], | ||
], | ||
[ | ||
'id and isOpened null return same rowdefs', | ||
[{ id: `afterRow-1`, hide: true }], | ||
null, | ||
null, | ||
[{ id: `afterRow-1`, hide: true }], | ||
], | ||
]; | ||
|
||
test.each(cases)('%s', (_title, rowDefs, id, isOpened, expected) => { | ||
expect(setHideRowDef(rowDefs, id, isOpened)).toEqual(expected); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
|
||
import { updateSelection } from './selection'; | ||
|
||
describe('updateSelection', () => { | ||
const cases: [string, string[], string, string[]][] = [ | ||
['return array with id', [], '1', ['1']], | ||
['return array without id', ['1'], '1', []], | ||
]; | ||
|
||
test.each(cases)('%s', (_title, selection, id, expected) => { | ||
expect(updateSelection(selection)(id)).toEqual(expected); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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