Skip to content

Commit 9c75721

Browse files
authored
refactor: fixes and moves all tests in core to new structure (#5841)
* feat: fixes and moves all tests in core to new structure * fix: removed uneeded helper file
1 parent 2860b8b commit 9c75721

File tree

9 files changed

+44
-84
lines changed

9 files changed

+44
-84
lines changed

packages/table-core/tests/RowSelection.test.ts renamed to packages/table-core/tests/implementation/features/row-pinning/rowSelectionFeature.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import {
44
coreFeatures,
55
createColumnHelper,
66
rowSelectionFeature,
7-
} from '../src'
8-
import * as RowSelectionUtils from '../src/features/row-selection/rowSelectionFeature.utils'
9-
import { makeData } from './makeTestData'
10-
import type { Person } from './makeTestData'
11-
import type { ColumnDef } from '../src'
7+
} from '../../../../src'
8+
import * as RowSelectionUtils from '../../../../src/features/row-selection/rowSelectionFeature.utils'
9+
import { makeData } from '../../../fixtures/data/makeData'
10+
import type { Person } from '../../../fixtures/data/types'
11+
import type { ColumnDef } from '../../../../src'
12+
13+
// TODO: bring up to new test structure
1214

1315
type personKeys = keyof Person
1416
type PersonColumn = ColumnDef<any, Person, any>

packages/table-core/tests/makeTestData.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

packages/table-core/tests/getGroupedRowModel.test.ts renamed to packages/table-core/tests/performance/features/column-grouping/columnGroupingFeature.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import {
55
constructTable,
66
coreFeatures,
77
createGroupedRowModel,
8-
} from '../src'
9-
import { createColumnHelper } from '../src/helpers/columnHelper'
10-
import { makeData } from './makeTestData'
11-
import type { Person } from './makeTestData'
12-
import type { ColumnDef } from '../src'
8+
} from '../../../../src'
9+
import { createColumnHelper } from '../../../../src/helpers/columnHelper'
10+
import { makeData } from '../../../fixtures/data/makeData'
11+
import type { Person } from '../../../fixtures/data/types'
12+
import type { ColumnDef } from '../../../../src'
13+
14+
// TODO: bring up to new test structure
1315

1416
type personKeys = keyof Person
1517
type PersonColumn = ColumnDef<any, Person, any>

packages/table-core/src/core/cells/constructCell.test.ts renamed to packages/table-core/tests/unit/core/cells/constructCell.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { describe, expect, it } from 'vitest'
2-
import { constructCell } from './constructCell'
3-
import { coreCellsFeature } from './coreCellsFeature'
4-
import type { Row } from '../../types/Row'
5-
import type { Column } from '../../types/Column'
6-
import type { Table } from '../../types/Table'
2+
import { constructCell } from '../../../../src/core/cells/constructCell'
3+
import { coreCellsFeature } from '../../../../src/core/cells/coreCellsFeature'
4+
import type { Row } from '../../../../src/types/Row'
5+
import type { Column } from '../../../../src/types/Column'
6+
import type { Table } from '../../../../src/types/Table'
77

88
describe('constructCell', () => {
99
it('should populate the cell with all core cell APIs and properties', () => {

packages/table-core/src/core/columns/constructColumn.test.ts renamed to packages/table-core/tests/unit/core/columns/constructColumn.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { describe, expect, it } from 'vitest'
2-
import { coreColumnsFeature } from './coreColumnsFeature'
3-
import { constructColumn } from './constructColumn'
4-
import type { Table } from '../../types/Table'
5-
import type { ColumnDef } from '../../types/ColumnDef'
2+
import { coreColumnsFeature } from '../../../../src/core/columns/coreColumnsFeature'
3+
import { constructColumn } from '../../../../src/core/columns/constructColumn'
4+
import { constructTable } from '../../../../src'
5+
import type { ColumnDef } from '../../../../src/types/ColumnDef'
66

77
describe('constructColumn', () => {
88
it('should create a column with all core column APIs and properties', () => {
9-
const table = { _features: { coreColumnsFeature }, options: {} } as Table<
10-
any,
11-
any
12-
>
9+
const table = constructTable({
10+
_features: { coreColumnsFeature },
11+
columns: [] as Array<any>,
12+
data: [] as Array<any>,
13+
})
14+
1315
const columnDef = {
1416
id: 'test-column',
1517
accessorKey: 'test-accessor-key',

packages/table-core/src/core/headers/constructHeader.test.ts renamed to packages/table-core/tests/unit/core/headers/constructHeader.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { describe, expect, it } from 'vitest'
2-
import { coreHeadersFeature } from './coreHeadersFeature'
3-
import { constructHeader } from './constructHeader'
4-
import type { Column } from '../../types/Column'
5-
import type { Table } from '../../types/Table'
2+
import { coreHeadersFeature } from '../../../../src/core/headers/coreHeadersFeature'
3+
import { constructHeader } from '../../../../src/core/headers/constructHeader'
4+
import type { Column } from '../../../../src/types/Column'
5+
import type { Table } from '../../../../src/types/Table'
66

77
describe('constructHeader', () => {
88
it('should create a column with all core column APIs and properties', () => {

packages/table-core/src/core/rows/constructRow.test.ts renamed to packages/table-core/tests/unit/core/rows/constructRow.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { describe, expect, it } from 'vitest'
2-
import { coreRowsFeature } from './coreRowsFeature'
3-
import { constructRow } from './constructRow'
4-
import type { Table } from '../../types/Table'
5-
import type { Row } from '../../types/Row'
2+
import { coreRowsFeature } from '../../../../src/core/rows/coreRowsFeature'
3+
import { constructRow } from '../../../../src/core/rows/constructRow'
4+
import type { Table } from '../../../../src/types/Table'
5+
import type { Row } from '../../../../src/types/Row'
66

77
interface Person {
88
firstName: string

packages/table-core/src/core/table/constructTable.test.ts renamed to packages/table-core/tests/unit/core/table/constructTable.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { describe, expect, it } from 'vitest'
2-
import { stockFeatures } from '../../features/stockFeatures'
3-
import { constructTable } from './constructTable'
2+
import { constructTable, coreFeatures } from '../../../../src'
43

54
describe('constructTable', () => {
65
it('should create a table with all core table APIs and properties', () => {
76
const table = constructTable({
8-
_features: stockFeatures,
7+
_features: {
8+
...coreFeatures,
9+
},
910
columns: [],
1011
data: [],
1112
})
@@ -37,7 +38,6 @@ describe('constructTable', () => {
3738
expect(table).toHaveProperty('getRow')
3839

3940
// table APIs
40-
expect(table).toHaveProperty('_queue')
4141
expect(table).toHaveProperty('getCoreRowModel')
4242
expect(table).toHaveProperty('getRowModel')
4343
expect(table).toHaveProperty('getState')

packages/table-core/src/utils.test.ts renamed to packages/table-core/tests/unit/utils.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { describe, expect, it } from 'vitest'
2-
import { getFunctionNameInfo } from './utils'
2+
import { getFunctionNameInfo } from '../../src/utils'
3+
4+
// TODO: add unit tests for rest of utils
35

46
describe('getFunctionNameInfo', () => {
57
it('should correctly parse a function with a standard name', () => {

0 commit comments

Comments
 (0)