-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate more test to use
vitest-browser-react
and browserUserEvent
(
#3633) * Use `@vitest/browser` * Update grouping tests * Update `userEvent`
- Loading branch information
1 parent
50e9a30
commit 8b0de36
Showing
13 changed files
with
234 additions
and
208 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
import type { Column } from '../../../src'; | ||
import { cellClassname } from '../../../src/style/cell'; | ||
import { getCells, setup } from '../utils'; | ||
import { getCellsNew, setupNew } from '../utils'; | ||
|
||
interface Row { | ||
id: number; | ||
} | ||
|
||
const rows: readonly Row[] = [{ id: 0 }, { id: 1 }]; | ||
|
||
test('cellClass is undefined', () => { | ||
test('cellClass is undefined', async () => { | ||
const columns: readonly Column<Row>[] = [ | ||
{ | ||
key: 'id', | ||
name: 'ID' | ||
} | ||
]; | ||
setup({ columns, rows }); | ||
const [cell1, cell2] = getCells(); | ||
expect(cell1).toHaveClass(cellClassname, { exact: true }); | ||
expect(cell2).toHaveClass(cellClassname, { exact: true }); | ||
setupNew({ columns, rows }); | ||
const [cell1, cell2] = getCellsNew(); | ||
await expect.element(cell1).toHaveClass(cellClassname, { exact: true }); | ||
await expect.element(cell2).toHaveClass(cellClassname, { exact: true }); | ||
}); | ||
|
||
test('cellClass is a string', () => { | ||
test('cellClass is a string', async () => { | ||
const columns: readonly Column<Row>[] = [ | ||
{ | ||
key: 'id', | ||
name: 'ID', | ||
cellClass: 'my-cell' | ||
} | ||
]; | ||
setup({ columns, rows }); | ||
const [cell1, cell2] = getCells(); | ||
expect(cell1).toHaveClass(`${cellClassname} my-cell`, { exact: true }); | ||
expect(cell2).toHaveClass(`${cellClassname} my-cell`, { exact: true }); | ||
setupNew({ columns, rows }); | ||
const [cell1, cell2] = getCellsNew(); | ||
await expect.element(cell1).toHaveClass(`${cellClassname} my-cell`, { exact: true }); | ||
await expect.element(cell2).toHaveClass(`${cellClassname} my-cell`, { exact: true }); | ||
}); | ||
|
||
test('cellClass returns a string', () => { | ||
test('cellClass returns a string', async () => { | ||
const columns: readonly Column<Row>[] = [ | ||
{ | ||
key: 'id', | ||
name: 'ID', | ||
cellClass: (row) => `my-cell-${row.id}` | ||
} | ||
]; | ||
setup({ columns, rows }); | ||
const [cell1, cell2] = getCells(); | ||
expect(cell1).toHaveClass(`${cellClassname} my-cell-0`, { exact: true }); | ||
expect(cell2).toHaveClass(`${cellClassname} my-cell-1`, { exact: true }); | ||
setupNew({ columns, rows }); | ||
const [cell1, cell2] = getCellsNew(); | ||
await expect.element(cell1).toHaveClass(`${cellClassname} my-cell-0`, { exact: true }); | ||
await expect.element(cell2).toHaveClass(`${cellClassname} my-cell-1`, { exact: true }); | ||
}); | ||
|
||
test('cellClass returns undefined', () => { | ||
test('cellClass returns undefined', async () => { | ||
const columns: readonly Column<Row>[] = [ | ||
{ | ||
key: 'id', | ||
name: 'ID', | ||
cellClass: () => undefined | ||
} | ||
]; | ||
setup({ columns, rows }); | ||
const [cell1, cell2] = getCells(); | ||
expect(cell1).toHaveClass(cellClassname, { exact: true }); | ||
expect(cell2).toHaveClass(cellClassname, { exact: true }); | ||
setupNew({ columns, rows }); | ||
const [cell1, cell2] = getCellsNew(); | ||
await expect.element(cell1).toHaveClass(cellClassname, { exact: true }); | ||
await expect.element(cell2).toHaveClass(cellClassname, { exact: true }); | ||
}); |
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 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
Oops, something went wrong.