|
| 1 | +/** |
| 2 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
| 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 | + |
| 9 | +import HasteMap from 'jest-haste-map'; |
| 10 | +import Runtime from '../'; |
| 11 | + |
| 12 | +jest.mock('jest-haste-map'); |
| 13 | + |
| 14 | +describe('Runtime statics', () => { |
| 15 | + const projectConfig = { |
| 16 | + cacheDirectory: '/tmp', |
| 17 | + haste: {}, |
| 18 | + modulePathIgnorePatterns: ['/root/ignore-1', '/root/ignore-2'], |
| 19 | + watchPathIgnorePatterns: ['/watch-root/ignore-1'], |
| 20 | + }; |
| 21 | + const options = {}; |
| 22 | + |
| 23 | + beforeEach(() => { |
| 24 | + jest.clearAllMocks(); |
| 25 | + }); |
| 26 | + |
| 27 | + test('Runtime.createHasteMap passes correct ignore files to HasteMap', () => { |
| 28 | + Runtime.createHasteMap(projectConfig, options); |
| 29 | + expect(HasteMap).toBeCalledWith( |
| 30 | + expect.objectContaining({ |
| 31 | + ignorePattern: /\/root\/ignore-1|\/root\/ignore-2/, |
| 32 | + }), |
| 33 | + ); |
| 34 | + }); |
| 35 | + |
| 36 | + test('Runtime.createHasteMap passes correct ignore files to HasteMap in watch mode', () => { |
| 37 | + Runtime.createHasteMap(projectConfig, {...options, watch: true}); |
| 38 | + expect(HasteMap).toBeCalledWith( |
| 39 | + expect.objectContaining({ |
| 40 | + ignorePattern: /\/root\/ignore-1|\/root\/ignore-2|\/watch-root\/ignore-1/, |
| 41 | + watch: true, |
| 42 | + }), |
| 43 | + ); |
| 44 | + }); |
| 45 | +}); |
0 commit comments