2021-09-06 20:15:10 +02:00
|
|
|
import { toPath } from '../src/util/toPath'
|
2023-01-20 12:45:04 -05:00
|
|
|
import { crosscheck } from './util/run'
|
2021-09-06 20:15:10 +02:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
crosscheck(() => {
|
|
|
|
|
it('should keep an array as an array', () => {
|
|
|
|
|
let input = ['a', 'b', '0', 'c']
|
2021-09-06 20:15:10 +02:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
expect(toPath(input)).toBe(input)
|
|
|
|
|
})
|
2021-09-06 20:15:10 +02:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
it.each`
|
|
|
|
|
input | output
|
|
|
|
|
${'a.b.c'} | ${['a', 'b', 'c']}
|
|
|
|
|
${'a[0].b.c'} | ${['a', '0', 'b', 'c']}
|
|
|
|
|
${'.a'} | ${['a']}
|
|
|
|
|
${'[].a'} | ${['a']}
|
|
|
|
|
${'a[1.5][b][c]'} | ${['a', '1.5', 'b', 'c']}
|
|
|
|
|
`('should convert "$input" to "$output"', ({ input, output }) => {
|
|
|
|
|
expect(toPath(input)).toEqual(output)
|
|
|
|
|
})
|
2021-09-06 20:15:10 +02:00
|
|
|
})
|