to-path.test.js 513 B

12345678910111213141516171819
  1. import { toPath } from '../src/util/toPath'
  2. it('should keep an array as an array', () => {
  3. let input = ['a', 'b', '0', 'c']
  4. expect(toPath(input)).toBe(input)
  5. })
  6. it.each`
  7. input | output
  8. ${'a.b.c'} | ${['a', 'b', 'c']}
  9. ${'a[0].b.c'} | ${['a', '0', 'b', 'c']}
  10. ${'.a'} | ${['a']}
  11. ${'[].a'} | ${['a']}
  12. ${'a[1.5][b][c]'} | ${['a', '1.5', 'b', 'c']}
  13. `('should convert "$input" to "$output"', ({ input, output }) => {
  14. expect(toPath(input)).toEqual(output)
  15. })