diff --git a/packages/table-core/tests/RowSelection.test.ts b/packages/table-core/tests/implementation/features/row-pinning/rowSelectionFeature.test.ts similarity index 96% rename from packages/table-core/tests/RowSelection.test.ts rename to packages/table-core/tests/implementation/features/row-pinning/rowSelectionFeature.test.ts index e6213d5f7b..55994c39b2 100644 --- a/packages/table-core/tests/RowSelection.test.ts +++ b/packages/table-core/tests/implementation/features/row-pinning/rowSelectionFeature.test.ts @@ -4,11 +4,13 @@ import { coreFeatures, createColumnHelper, rowSelectionFeature, -} from '../src' -import * as RowSelectionUtils from '../src/features/row-selection/rowSelectionFeature.utils' -import { makeData } from './makeTestData' -import type { Person } from './makeTestData' -import type { ColumnDef } from '../src' +} from '../../../../src' +import * as RowSelectionUtils from '../../../../src/features/row-selection/rowSelectionFeature.utils' +import { makeData } from '../../../fixtures/data/makeData' +import type { Person } from '../../../fixtures/data/types' +import type { ColumnDef } from '../../../../src' + +// TODO: bring up to new test structure type personKeys = keyof Person type PersonColumn = ColumnDef diff --git a/packages/table-core/tests/makeTestData.ts b/packages/table-core/tests/makeTestData.ts deleted file mode 100644 index b2db77cb6d..0000000000 --- a/packages/table-core/tests/makeTestData.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { faker } from '@faker-js/faker' - -export type Person = { - firstName: string - lastName: string - age: number - visits: number - progress: number - status: 'relationship' | 'complicated' | 'single' - subRows?: Array -} - -const range = (len: number) => { - const arr: Array = [] - for (let i = 0; i < len; i++) { - arr.push(i) - } - return arr -} - -const newPerson = (): Person => { - return { - firstName: faker.person.firstName(), - lastName: faker.person.lastName(), - age: faker.number.int(40), - visits: faker.number.int(1000), - progress: faker.number.int(100), - status: faker.helpers.shuffle([ - 'relationship', - 'complicated', - 'single', - ])[0]!, - } -} - -export function makeData(...lens: Array) { - const makeDataLevel = (depth = 0): Array => { - const len = lens[depth]! - return range(len).map((d): Person => { - return { - ...newPerson(), - subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined, - } - }) - } - - return makeDataLevel() -} diff --git a/packages/table-core/tests/getGroupedRowModel.test.ts b/packages/table-core/tests/performance/features/column-grouping/columnGroupingFeature.test.ts similarity index 85% rename from packages/table-core/tests/getGroupedRowModel.test.ts rename to packages/table-core/tests/performance/features/column-grouping/columnGroupingFeature.test.ts index 0447113fdb..4cc7cb50eb 100644 --- a/packages/table-core/tests/getGroupedRowModel.test.ts +++ b/packages/table-core/tests/performance/features/column-grouping/columnGroupingFeature.test.ts @@ -5,11 +5,13 @@ import { constructTable, coreFeatures, createGroupedRowModel, -} from '../src' -import { createColumnHelper } from '../src/helpers/columnHelper' -import { makeData } from './makeTestData' -import type { Person } from './makeTestData' -import type { ColumnDef } from '../src' +} from '../../../../src' +import { createColumnHelper } from '../../../../src/helpers/columnHelper' +import { makeData } from '../../../fixtures/data/makeData' +import type { Person } from '../../../fixtures/data/types' +import type { ColumnDef } from '../../../../src' + +// TODO: bring up to new test structure type personKeys = keyof Person type PersonColumn = ColumnDef diff --git a/packages/table-core/src/core/cells/constructCell.test.ts b/packages/table-core/tests/unit/core/cells/constructCell.test.ts similarity index 73% rename from packages/table-core/src/core/cells/constructCell.test.ts rename to packages/table-core/tests/unit/core/cells/constructCell.test.ts index 1e74bd4c41..ab88f2e968 100644 --- a/packages/table-core/src/core/cells/constructCell.test.ts +++ b/packages/table-core/tests/unit/core/cells/constructCell.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from 'vitest' -import { constructCell } from './constructCell' -import { coreCellsFeature } from './coreCellsFeature' -import type { Row } from '../../types/Row' -import type { Column } from '../../types/Column' -import type { Table } from '../../types/Table' +import { constructCell } from '../../../../src/core/cells/constructCell' +import { coreCellsFeature } from '../../../../src/core/cells/coreCellsFeature' +import type { Row } from '../../../../src/types/Row' +import type { Column } from '../../../../src/types/Column' +import type { Table } from '../../../../src/types/Table' describe('constructCell', () => { it('should populate the cell with all core cell APIs and properties', () => { diff --git a/packages/table-core/src/core/columns/constructColumn.test.ts b/packages/table-core/tests/unit/core/columns/constructColumn.test.ts similarity index 68% rename from packages/table-core/src/core/columns/constructColumn.test.ts rename to packages/table-core/tests/unit/core/columns/constructColumn.test.ts index 00c67cae10..094d195fc6 100644 --- a/packages/table-core/src/core/columns/constructColumn.test.ts +++ b/packages/table-core/tests/unit/core/columns/constructColumn.test.ts @@ -1,15 +1,17 @@ import { describe, expect, it } from 'vitest' -import { coreColumnsFeature } from './coreColumnsFeature' -import { constructColumn } from './constructColumn' -import type { Table } from '../../types/Table' -import type { ColumnDef } from '../../types/ColumnDef' +import { coreColumnsFeature } from '../../../../src/core/columns/coreColumnsFeature' +import { constructColumn } from '../../../../src/core/columns/constructColumn' +import { constructTable } from '../../../../src' +import type { ColumnDef } from '../../../../src/types/ColumnDef' describe('constructColumn', () => { it('should create a column with all core column APIs and properties', () => { - const table = { _features: { coreColumnsFeature }, options: {} } as Table< - any, - any - > + const table = constructTable({ + _features: { coreColumnsFeature }, + columns: [] as Array, + data: [] as Array, + }) + const columnDef = { id: 'test-column', accessorKey: 'test-accessor-key', diff --git a/packages/table-core/src/core/headers/constructHeader.test.ts b/packages/table-core/tests/unit/core/headers/constructHeader.test.ts similarity index 80% rename from packages/table-core/src/core/headers/constructHeader.test.ts rename to packages/table-core/tests/unit/core/headers/constructHeader.test.ts index 8d8562d665..fdfe777152 100644 --- a/packages/table-core/src/core/headers/constructHeader.test.ts +++ b/packages/table-core/tests/unit/core/headers/constructHeader.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from 'vitest' -import { coreHeadersFeature } from './coreHeadersFeature' -import { constructHeader } from './constructHeader' -import type { Column } from '../../types/Column' -import type { Table } from '../../types/Table' +import { coreHeadersFeature } from '../../../../src/core/headers/coreHeadersFeature' +import { constructHeader } from '../../../../src/core/headers/constructHeader' +import type { Column } from '../../../../src/types/Column' +import type { Table } from '../../../../src/types/Table' describe('constructHeader', () => { it('should create a column with all core column APIs and properties', () => { diff --git a/packages/table-core/src/core/rows/constructRow.test.ts b/packages/table-core/tests/unit/core/rows/constructRow.test.ts similarity index 86% rename from packages/table-core/src/core/rows/constructRow.test.ts rename to packages/table-core/tests/unit/core/rows/constructRow.test.ts index b8b3e01dd6..88f079fa3a 100644 --- a/packages/table-core/src/core/rows/constructRow.test.ts +++ b/packages/table-core/tests/unit/core/rows/constructRow.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from 'vitest' -import { coreRowsFeature } from './coreRowsFeature' -import { constructRow } from './constructRow' -import type { Table } from '../../types/Table' -import type { Row } from '../../types/Row' +import { coreRowsFeature } from '../../../../src/core/rows/coreRowsFeature' +import { constructRow } from '../../../../src/core/rows/constructRow' +import type { Table } from '../../../../src/types/Table' +import type { Row } from '../../../../src/types/Row' interface Person { firstName: string diff --git a/packages/table-core/src/core/table/constructTable.test.ts b/packages/table-core/tests/unit/core/table/constructTable.test.ts similarity index 89% rename from packages/table-core/src/core/table/constructTable.test.ts rename to packages/table-core/tests/unit/core/table/constructTable.test.ts index a060547d9e..275118190f 100644 --- a/packages/table-core/src/core/table/constructTable.test.ts +++ b/packages/table-core/tests/unit/core/table/constructTable.test.ts @@ -1,11 +1,12 @@ import { describe, expect, it } from 'vitest' -import { stockFeatures } from '../../features/stockFeatures' -import { constructTable } from './constructTable' +import { constructTable, coreFeatures } from '../../../../src' describe('constructTable', () => { it('should create a table with all core table APIs and properties', () => { const table = constructTable({ - _features: stockFeatures, + _features: { + ...coreFeatures, + }, columns: [], data: [], }) @@ -37,7 +38,6 @@ describe('constructTable', () => { expect(table).toHaveProperty('getRow') // table APIs - expect(table).toHaveProperty('_queue') expect(table).toHaveProperty('getCoreRowModel') expect(table).toHaveProperty('getRowModel') expect(table).toHaveProperty('getState') diff --git a/packages/table-core/src/utils.test.ts b/packages/table-core/tests/unit/utils.test.ts similarity index 90% rename from packages/table-core/src/utils.test.ts rename to packages/table-core/tests/unit/utils.test.ts index 4caac807fc..c599e0c39e 100644 --- a/packages/table-core/src/utils.test.ts +++ b/packages/table-core/tests/unit/utils.test.ts @@ -1,5 +1,7 @@ import { describe, expect, it } from 'vitest' -import { getFunctionNameInfo } from './utils' +import { getFunctionNameInfo } from '../../src/utils' + +// TODO: add unit tests for rest of utils describe('getFunctionNameInfo', () => { it('should correctly parse a function with a standard name', () => {