| 
 | 1 | +import { bracketNameGenerator, dotNotationNameGenerator } from '../src';  | 
 | 2 | + | 
 | 3 | +describe('bracketNameGenerator()', () => {  | 
 | 4 | +  test('returns "root" for empty path', () => {  | 
 | 5 | +    expect(bracketNameGenerator([], 'root')).toBe('root');  | 
 | 6 | +  });  | 
 | 7 | + | 
 | 8 | +  test('generates name for single string segment', () => {  | 
 | 9 | +    expect(bracketNameGenerator(['firstName'], 'root')).toBe('root[firstName]');  | 
 | 10 | +  });  | 
 | 11 | + | 
 | 12 | +  test('generates name for single number segment (array index)', () => {  | 
 | 13 | +    expect(bracketNameGenerator([0], 'root')).toBe('root[0]');  | 
 | 14 | +  });  | 
 | 15 | + | 
 | 16 | +  test('generates name for nested object path', () => {  | 
 | 17 | +    expect(bracketNameGenerator(['user', 'address', 'city'], 'root')).toBe('root[user][address][city]');  | 
 | 18 | +  });  | 
 | 19 | + | 
 | 20 | +  test('generates name for array with object properties', () => {  | 
 | 21 | +    expect(bracketNameGenerator(['tasks', 0, 'title'], 'root')).toBe('root[tasks][0][title]');  | 
 | 22 | +  });  | 
 | 23 | + | 
 | 24 | +  test('generates name for nested arrays', () => {  | 
 | 25 | +    expect(bracketNameGenerator(['matrix', 0, 1], 'root')).toBe('root[matrix][0][1]');  | 
 | 26 | +  });  | 
 | 27 | + | 
 | 28 | +  test('generates name for complex nested structure', () => {  | 
 | 29 | +    expect(bracketNameGenerator(['users', 0, 'addresses', 1, 'street'], 'root')).toBe(  | 
 | 30 | +      'root[users][0][addresses][1][street]',  | 
 | 31 | +    );  | 
 | 32 | +  });  | 
 | 33 | +});  | 
 | 34 | + | 
 | 35 | +describe('dotNotationNameGenerator()', () => {  | 
 | 36 | +  test('returns "root" for empty path', () => {  | 
 | 37 | +    expect(dotNotationNameGenerator([], 'root')).toBe('root');  | 
 | 38 | +  });  | 
 | 39 | + | 
 | 40 | +  test('generates name for single string segment', () => {  | 
 | 41 | +    expect(dotNotationNameGenerator(['firstName'], 'root')).toBe('root.firstName');  | 
 | 42 | +  });  | 
 | 43 | + | 
 | 44 | +  test('generates name for single number segment (array index)', () => {  | 
 | 45 | +    expect(dotNotationNameGenerator([0], 'root')).toBe('root.0');  | 
 | 46 | +  });  | 
 | 47 | + | 
 | 48 | +  test('generates name for nested object path', () => {  | 
 | 49 | +    expect(dotNotationNameGenerator(['user', 'address', 'city'], 'root')).toBe('root.user.address.city');  | 
 | 50 | +  });  | 
 | 51 | + | 
 | 52 | +  test('generates name for array with object properties', () => {  | 
 | 53 | +    expect(dotNotationNameGenerator(['tasks', 0, 'title'], 'root')).toBe('root.tasks.0.title');  | 
 | 54 | +  });  | 
 | 55 | + | 
 | 56 | +  test('generates name for nested arrays', () => {  | 
 | 57 | +    expect(dotNotationNameGenerator(['matrix', 0, 1], 'root')).toBe('root.matrix.0.1');  | 
 | 58 | +  });  | 
 | 59 | + | 
 | 60 | +  test('generates name for complex nested structure', () => {  | 
 | 61 | +    expect(dotNotationNameGenerator(['users', 0, 'addresses', 1, 'street'], 'root')).toBe(  | 
 | 62 | +      'root.users.0.addresses.1.street',  | 
 | 63 | +    );  | 
 | 64 | +  });  | 
 | 65 | +});  | 
0 commit comments