|
| 1 | +/** |
| 2 | + * Copyright (c) 2015-present, Facebook, Inc. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +'use strict'; |
| 9 | + |
| 10 | +const ignoredFiles = require('../ignoredFiles'); |
| 11 | + |
| 12 | +describe('ignore watch files regex', () => { |
| 13 | + it('normal file', () => { |
| 14 | + const appSrc = '/root/src/'; |
| 15 | + const isIgnored = ignoredFiles(appSrc).test('/foo'); |
| 16 | + const isIgnoredInSrc = ignoredFiles(appSrc).test('/root/src/foo'); |
| 17 | + |
| 18 | + expect(isIgnored).toBe(false); |
| 19 | + expect(isIgnoredInSrc).toBe(false); |
| 20 | + }); |
| 21 | + |
| 22 | + it('node modules', () => { |
| 23 | + const appSrc = '/root/src/'; |
| 24 | + const isIgnored = ignoredFiles(appSrc).test('/root/node_modules/foo'); |
| 25 | + |
| 26 | + expect(isIgnored).toBe(true); |
| 27 | + }); |
| 28 | + |
| 29 | + it('node modules inside source directory', () => { |
| 30 | + const appSrc = '/root/src/'; |
| 31 | + const isIgnored = ignoredFiles(appSrc).test('/root/src/node_modules/foo'); |
| 32 | + const isIgnoredMoreThanOneLevel = ignoredFiles(appSrc).test( |
| 33 | + '/root/src/bar/node_modules/foo' |
| 34 | + ); |
| 35 | + |
| 36 | + expect(isIgnored).toBe(false); |
| 37 | + expect(isIgnoredMoreThanOneLevel).toBe(false); |
| 38 | + }); |
| 39 | + |
| 40 | + it('path contains source directory', () => { |
| 41 | + const appSrc = '/root/src/'; |
| 42 | + const isIgnored = ignoredFiles(appSrc).test( |
| 43 | + '/bar/root/src/node_modules/foo' |
| 44 | + ); |
| 45 | + |
| 46 | + expect(isIgnored).toBe(true); |
| 47 | + }); |
| 48 | + |
| 49 | + it('path starts with source directory', () => { |
| 50 | + const appSrc = '/root/src/'; |
| 51 | + const isIgnored = ignoredFiles(appSrc).test('/root/src2/node_modules/foo'); |
| 52 | + |
| 53 | + expect(isIgnored).toBe(true); |
| 54 | + }); |
| 55 | +}); |
0 commit comments