|
| 1 | +import { createIsIgnored } from '../../../src/watch/inclusive-node-watch-file-system'; |
| 2 | + |
| 3 | +describe('createIsIgnored', () => { |
| 4 | + const gitPath = '/path/to/.git/foo'; |
| 5 | + const nodeModulesPath = '/path/to/node_modules/foo/dist/index.js'; |
| 6 | + const distModulePath = '/path/to/dist/foo.js'; |
| 7 | + const srcModulePath = '/path/to/src/foo.ts'; |
| 8 | + |
| 9 | + it('should allow to passing RegExp to the first argument', () => { |
| 10 | + const isIgnored = createIsIgnored([/[\\/](?:\.git|node_modules)[\\/]/], []); |
| 11 | + expect(isIgnored(gitPath)).toBe(true); |
| 12 | + expect(isIgnored(nodeModulesPath)).toBe(true); |
| 13 | + expect(isIgnored(distModulePath)).toBe(false); |
| 14 | + expect(isIgnored(srcModulePath)).toBe(false); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should allow to passing string path to the first argument', () => { |
| 18 | + const isIgnored = createIsIgnored(['/path/to/.git'], []); |
| 19 | + expect(isIgnored(gitPath)).toBe(true); |
| 20 | + expect(isIgnored(nodeModulesPath)).toBe(false); |
| 21 | + expect(isIgnored(distModulePath)).toBe(false); |
| 22 | + expect(isIgnored(srcModulePath)).toBe(false); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should allow to passing string path to the second argument', () => { |
| 26 | + const isIgnored = createIsIgnored([], ['/path/to/dist']); |
| 27 | + expect(isIgnored(gitPath)).toBe(true); |
| 28 | + expect(isIgnored(nodeModulesPath)).toBe(false); |
| 29 | + expect(isIgnored(distModulePath)).toBe(true); |
| 30 | + expect(isIgnored(srcModulePath)).toBe(false); |
| 31 | + }); |
| 32 | +}); |
0 commit comments