Skip to content

Commit

Permalink
refactor: fixes and moves all tests in core to new structure (#5841)
Browse files Browse the repository at this point in the history
* feat: fixes and moves all tests in core to new structure

* fix: removed uneeded helper file
  • Loading branch information
will-short authored Dec 21, 2024
1 parent 2860b8b commit 9c75721
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, Person, any>
Expand Down
48 changes: 0 additions & 48 deletions packages/table-core/tests/makeTestData.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<any, Person, any>
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<any>,
data: [] as Array<any>,
})

const columnDef = {
id: 'test-column',
accessorKey: 'test-accessor-key',
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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: [],
})
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down

0 comments on commit 9c75721

Please sign in to comment.