antler
Version:
Directory structure linter
43 lines (34 loc) • 1.13 kB
text/typescript
import { RegexRule } from '../../src/regex-rule';
import { Path } from '../../src/rules/path';
import { Node } from '../../src/types';
describe('Path', () => {
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 Path({ level: 'error', options: { allow: '' } });
expect(instance instanceof RegexRule).toBe(true);
});
describe('shouldRun', () => {
it('should run only for any type', () => {
const instance = new Path({ level: 'error', options: { allow: '' } });
expect(instance['shouldRun']()).toBe(true);
});
});
describe('getPart', () => {
it('should return the file path', () => {
const instance = new Path({ level: 'error', options: { allow: '' } });
expect(instance['getPart'](directoryNode)).toBe('parent/child.json');
});
});
});