Skip to content

Commit

Permalink
DEV tablehelpers, tableHeader tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Aug 11, 2022
1 parent 04baec1 commit 85d039b
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
100 changes: 100 additions & 0 deletions src/components/table/__tests__/__snapshots__/tableHelpers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,103 @@ Object {
"tableRows": [Function],
}
`;

exports[`TableHelpers tableHeader should return parsed table header settings, props: tableHeader 1`] = `
Object {
"allRowsSelected": Object {
"columnHeaders": Array [],
"headerSelectProps": Object {},
"isSortTable": false,
},
"basic": Object {
"columnHeaders": Array [],
"headerSelectProps": Object {},
"isSortTable": false,
},
"columnHeaders": Object {
"columnHeaders": Array [
Object {
"content": "lorem",
},
Object {
"content": "dolor",
"props": Object {},
},
Object {
"content": "hello world",
},
],
"headerSelectProps": Object {},
"isSortTable": false,
},
"isRowExpand": Object {
"columnHeaders": Array [
Object {
"content": "lorem",
},
Object {
"content": "dolor",
"props": Object {
"sort": Object {
"columnIndex": 2,
"onSort": [Function],
"sortBy": Object {
"direction": "asc",
},
},
},
},
Object {
"content": "hello world",
},
],
"headerSelectProps": Object {},
"isSortTable": true,
},
"onSelect": Object {
"columnHeaders": Array [
Object {
"content": "lorem",
},
Object {
"content": "dolor",
"props": Object {},
},
Object {
"content": "hello world",
},
],
"headerSelectProps": Object {
"select": Object {
"isSelected": false,
"onSelect": [Function],
},
},
"isSortTable": false,
},
"onSort": Object {
"columnHeaders": Array [
Object {
"content": "lorem",
},
Object {
"content": "dolor",
"props": Object {
"sort": Object {
"columnIndex": 1,
"onSort": [Function],
"sortBy": Object {
"direction": "asc",
},
},
},
},
Object {
"content": "hello world",
},
],
"headerSelectProps": Object {},
"isSortTable": true,
},
}
`;
21 changes: 21 additions & 0 deletions src/components/table/__tests__/tableHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,25 @@ describe('TableHelpers', () => {
repeatNumber: generateTableKey(200)
}).toMatchSnapshot('keys');
});

it('tableHeader should return parsed table header settings, props', () => {
expect({
basic: tableHeader(),
allRowsSelected: tableHeader({ allRowsSelected: true }),
columnHeaders: tableHeader({ columnHeaders: ['lorem', { content: 'dolor' }, () => 'hello world'] }),
onSelect: tableHeader({
onSelect: () => {},
columnHeaders: ['lorem', { content: 'dolor' }, () => 'hello world']
}),
onSort: tableHeader({
onSort: () => {},
columnHeaders: ['lorem', { content: 'dolor', isSort: true }, () => 'hello world']
}),
isRowExpand: tableHeader({
onSort: () => {},
isRowExpand: true,
columnHeaders: ['lorem', { content: 'dolor', isSort: true }, () => 'hello world']
})
}).toMatchSnapshot('tableHeader');
});
});

0 comments on commit 85d039b

Please sign in to comment.