UNPKG

antler

Version:
50 lines (41 loc) 1.26 kB
import { RegexRule } from '../../src/regex-rule'; import { Extension } from '../../src/rules/extension'; import { Node } from '../../src/types'; describe('Extension', () => { const fileNode: Node = { fullPath: 'root/parent/child.json', path: 'parent/child.json', name: 'child.json', parentName: 'parent', siblingNamesIncludingSelf: ['child.json'], childNames: [], isDirectory: false, }; const directoryNode = { ...fileNode, isDirectory: true, }; it('should extend RegexRule', () => { const instance = new Extension({ level: 'error', options: { allow: '' } }); expect(instance instanceof RegexRule).toBe(true); }); describe('shouldRun', () => { it('should run only for files', () => { const instance = new Extension({ level: 'error', options: { allow: '' }, }); expect(instance['shouldRun'](fileNode)).toBe(true); expect(instance['shouldRun'](directoryNode)).toBe(false); }); }); describe('getPart', () => { it('should return the file extension', () => { const instance = new Extension({ level: 'error', options: { allow: '' }, }); expect(instance['getPart'](directoryNode)).toBe('.json'); }); }); });