Jest fixes 7

This commit is contained in:
karilint
2026-03-18 11:01:14 +02:00
parent 2579ddade0
commit 2556f0ce09
3 changed files with 41 additions and 0 deletions
+2
View File
@@ -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',
+11
View File
@@ -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>
)