UNPKG

@naoufal/create-react-component

Version:
35 lines (28 loc) 1.04 kB
const { validatePath, validateName } = require('./validation'); describe('Validation', () => { describe('validatePath', () => { test('should return `false` when an empty string is passed', () => { expect(validatePath('')).toBe(false); }); test('should return `false` when an invalid path is passed', () => { expect(validatePath('./path/to/no/dir')).toBe(false); }); test('should return `true` when path provided is valid', () => { expect(validatePath('src')).toBe(true); }); }); describe('validateName', () => { test('should return `false` when an empty string is passed', () => { expect(validateName('')).toBe(false); }); test('should return `false` if a file with the same name already exists', () => { expect(validateName('src', { path: '.' })).toBe(false); }); test('should return `true` when name is not used by another file or directory', () => { expect(validateName('SomeComponentName', { path: '.' })).toBe(true); }); }); });