V13-FE-006: consolidate approved UI and contract hardening
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { toUiGridColumns } from '../gridColumnAdapter'
|
||||
|
||||
describe('toUiGridColumns', () => {
|
||||
it('preserves the provider-neutral column semantics and formatter', () => {
|
||||
const formatter = (value: unknown) => String(value ?? '')
|
||||
|
||||
expect(toUiGridColumns([{
|
||||
field: 'modelId',
|
||||
header: 'Model ID',
|
||||
width: 150,
|
||||
sortable: false,
|
||||
filterable: true,
|
||||
formatter,
|
||||
}])).toEqual([{
|
||||
field: 'modelId',
|
||||
header: 'Model ID',
|
||||
width: 150,
|
||||
sortable: false,
|
||||
filterable: true,
|
||||
formatter,
|
||||
}])
|
||||
})
|
||||
|
||||
it('does not guess how string widths should be interpreted', () => {
|
||||
expect(toUiGridColumns([{ field: 'name', header: 'Name', width: '20rem' }])).toEqual([{
|
||||
field: 'name',
|
||||
header: 'Name',
|
||||
width: undefined,
|
||||
sortable: undefined,
|
||||
filterable: undefined,
|
||||
formatter: undefined,
|
||||
}])
|
||||
})
|
||||
|
||||
it('rejects non-string fields before they reach an adapter', () => {
|
||||
expect(() => toUiGridColumns([{ field: 1, header: 'Invalid' }])).toThrow('Grid column field must be a string')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user