Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Mar 6, 2024
1 parent f44edfc commit e031fed
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions @fiction/ui/test/inputOption.wip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('inputOptionsRefiner', () => {
const caller = 'test1'
const consoleWarnSpy = vi.spyOn(console, 'warn')
const refiner = new InputOptionsRefiner({ basePath: '', caller })
const r1 = refiner.refineInputOptions({ inputOptions, refineOption: { option1: { refine: { subOption1: true, subOptionNoExist: true } }, option2: true, option3Alias: { refine: { subAlias: true } } } })
const r1 = refiner.refineInputOptions({ inputOptions, refine: { option1: { refine: { subOption1: true, subOptionNoExist: true } }, option2: true, option3Alias: { refine: { subAlias: true } } } })

expect(r1[0].options.value?.length).toBe(1)
expect(r1[0].options.value?.[0].key.value).toBe('subOption1')
Expand All @@ -46,7 +46,7 @@ describe('inputOptionsRefiner', () => {
new InputOption({ key: 'option2' }),
]
const refiner = new InputOptionsRefiner({ basePath: '', caller: `test2` })
const r2 = refiner.refineInputOptions({ inputOptions, refineOption: { } })
const r2 = refiner.refineInputOptions({ inputOptions, refine: { } })

expect(r2).toEqual(inputOptions)
})
Expand All @@ -58,26 +58,26 @@ describe('inputOptionsRefiner', () => {
]

const consoleWarnSpy = vi.spyOn(console, 'warn')
const refineOption = { option1: true, option3: true }
const refine = { option1: true, option3: true }
const basePath = 'base'
const caller = `test3`
const refiner = new InputOptionsRefiner({ basePath, caller })
refiner.refineInputOptions({ inputOptions, refineOption })
refiner.refineInputOptions({ inputOptions, refine })

expect(consoleWarnSpy).toHaveBeenCalledWith(`Warning: Filter key 'option3' provided by '${caller}' was not used.`)
consoleWarnSpy.mockRestore()
})
it('filters options based on refineOption and prepends basePath at depth 0', () => {
it('filters options based on refine and prepends basePath at depth 0', () => {
const inputOptions = [
new InputOption({ key: 'option1', options: [new InputOption({ key: 'subOption1' })] }),
new InputOption({ key: 'option2' }),
]

const refineOption = { option1: true, option2: true }
const refine = { option1: true, option2: true }
const basePath = 'base'

const refiner = new InputOptionsRefiner({ basePath, caller: `test4` })
const result = refiner.refineInputOptions({ inputOptions, refineOption })
const result = refiner.refineInputOptions({ inputOptions, refine })

expect(result.length).toBe(2)
expect(result.length).toMatchInlineSnapshot(`2`)
Expand Down

0 comments on commit e031fed

Please sign in to comment.