UNPKG

zod-error

Version:

Utilities to format and customize Zod error messages

17 lines (16 loc) 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = require("."); const path = ['car', 'wheels', 0]; test('a zod path is converted to object notion by default', () => expect((0, _1.getPathString)(path)).toBe('car.wheels[0]')); test('a zod path is converted to object notation with default settings', () => expect((0, _1.getPathString)(path, { enabled: true, type: 'objectNotation' })).toBe('car.wheels[0]')); test('a zod path is converted to object notation with default settings', () => expect((0, _1.getPathString)(path, { enabled: true, type: 'objectNotation', arraySquareBrackets: false })).toBe('car.wheels.0')); test('a zod path is converted to a breadcrumbs path with default options', () => expect((0, _1.getPathString)(path, { enabled: true, type: 'breadcrumbs' })).toBe('car > wheels > [0]')); test('a zod path is converted to a breadcrumbs path with custom options', () => expect((0, _1.getPathString)(path, { enabled: true, type: 'breadcrumbs', arraySquareBrackets: false, delimeter: '#', })).toBe('car#wheels#0')); test('a zod path is converted to a zod path array string', () => expect((0, _1.getPathString)(path, { enabled: true, type: 'zodPathArray' })).toBe('["car", "wheels", 0]')); test('a zod path is converted to an empty path when the path is disabled', () => expect((0, _1.getPathString)(path, { enabled: false })).toBe(''));