mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Jest fixes 7
This commit is contained in:
@@ -12,6 +12,8 @@ export default {
|
||||
moduleNameMapper: {
|
||||
'^.+\\.css$': '<rootDir>/src/tests/mocks/styleMock.ts',
|
||||
'^.+\\.(svg|png|jpe?g|gif|webp)$': '<rootDir>/src/tests/mocks/fileMock.ts',
|
||||
'^material-react-table$': '<rootDir>/src/tests/mocks/materialReactTable.tsx',
|
||||
'^export-to-csv$': '<rootDir>/src/tests/mocks/exportToCsv.ts',
|
||||
'^@/util/config$': '<rootDir>/src/tests/mocks/config.ts',
|
||||
'^\\.\\.?/util/config$': '<rootDir>/src/tests/mocks/config.ts',
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export const mkConfig = <T,>(config: T) => config
|
||||
|
||||
export const generateCsv =
|
||||
<T,>(_config: T) =>
|
||||
(_rows: unknown) =>
|
||||
'csv'
|
||||
|
||||
export const download =
|
||||
<T,>(_config: T) =>
|
||||
(_csv: string) =>
|
||||
undefined
|
||||
@@ -0,0 +1,28 @@
|
||||
import { ReactNode } from 'react'
|
||||
|
||||
type MockRow = {
|
||||
original: Record<string, unknown>
|
||||
getVisibleCells: () => Array<{
|
||||
column: { id: string }
|
||||
getValue: () => unknown
|
||||
}>
|
||||
}
|
||||
|
||||
type MockTable = {
|
||||
getPrePaginationRowModel: () => { rows: MockRow[] }
|
||||
getColumn: (id: string) => { columnDef: { header: string } }
|
||||
}
|
||||
|
||||
export const useMaterialReactTable = <T extends object>(options: T): T & MockTable => ({
|
||||
...options,
|
||||
getPrePaginationRowModel: () => ({ rows: [] }),
|
||||
getColumn: (id: string) => ({ columnDef: { header: id } }),
|
||||
})
|
||||
|
||||
export const MaterialReactTable = ({ children }: { children?: ReactNode; table?: unknown }) => (
|
||||
<div data-testid="material-react-table">{children}</div>
|
||||
)
|
||||
|
||||
export const MRT_ShowHideColumnsButton = ({ children }: { children?: ReactNode; table?: unknown }) => (
|
||||
<button type="button">{children ?? 'Show/Hide Columns'}</button>
|
||||
)
|
||||
Reference in New Issue
Block a user