-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filterFns unit tests and rearrange some fixtures
- Loading branch information
1 parent
cf0972d
commit bce4188
Showing
15 changed files
with
537 additions
and
124 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
17 changes: 0 additions & 17 deletions
17
packages/table-core/tests/fixtures/data/generateColumns.ts
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
packages/table-core/tests/fixtures/data/generateTestColumnDefs.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,20 @@ | ||
import { createColumnHelper } from '../../../src' | ||
import type { Person, PersonColumn, PersonKeys } from './types' | ||
import type { TableFeatures } from '../../../src' | ||
|
||
export function generateTestColumnDefs<TFeatures extends TableFeatures>( | ||
people: Array<Person>, | ||
): Array<PersonColumn<TFeatures>> { | ||
const columnHelper = createColumnHelper<TFeatures, Person>() | ||
const person = people[0] | ||
|
||
if (!person) { | ||
return [] | ||
} | ||
|
||
return Object.keys(person).map((key) => { | ||
const typedKey = key as PersonKeys | ||
|
||
return columnHelper.accessor(typedKey, { id: typedKey } as any) | ||
}) | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
generateTestTableFromData, | ||
generateTestTableWithData, | ||
generateTestTableWithDataAndState, | ||
generateTestTableWithStateFromData, | ||
} from './generateTestTable' | ||
import type { TableFeatures, TableOptions } from '../../src' | ||
import type { Person } from '../fixtures/data/types' | ||
|
||
export function generateTestRowsWithData<TFeatures extends TableFeatures>( | ||
lengths: Array<number> | number = 10, | ||
options?: Omit<TableOptions<TFeatures, Person>, 'data' | 'columns'> & { | ||
_features?: TFeatures | ||
}, | ||
) { | ||
const testTable = generateTestTableWithData<TFeatures>(lengths, options) | ||
return testTable.getRowModel().rows | ||
} | ||
|
||
export function generateTestRowsFromData<TFeatures extends TableFeatures>( | ||
data: Array<Person>, | ||
options?: Omit<TableOptions<TFeatures, Person>, 'data' | 'columns'> & { | ||
_features?: TFeatures | ||
}, | ||
) { | ||
const testTable = generateTestTableFromData<TFeatures>(data, options) | ||
return testTable.getRowModel().rows | ||
} | ||
|
||
export function generateTestRowsWithState<TFeatures extends TableFeatures>( | ||
lengths: Array<number> | number = 10, | ||
options?: Omit< | ||
TableOptions<TFeatures, Person>, | ||
'data' | 'columns' | 'onStateChange' | ||
> & { | ||
_features?: TFeatures | ||
}, | ||
) { | ||
const testTable = generateTestTableWithDataAndState<TFeatures>( | ||
lengths, | ||
options, | ||
) | ||
return testTable.getRowModel().rows | ||
} | ||
|
||
export function generateTestRowsWithStateFromData< | ||
TFeatures extends TableFeatures, | ||
>( | ||
data: Array<Person>, | ||
options?: Omit< | ||
TableOptions<TFeatures, Person>, | ||
'data' | 'columns' | 'onStateChange' | ||
> & { | ||
_features?: TFeatures | ||
}, | ||
) { | ||
const testTable = generateTestTableWithStateFromData<TFeatures>(data, options) | ||
return testTable.getRowModel().rows | ||
} |
Oops, something went wrong.