react / wstein / node_modules / jest-cli / node_modules / node-haste / __tests__ / JSMockLoader-test.js
80668 views/**1* Copyright 2013 Facebook, Inc.2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*15* @emails [email protected] [email protected]16*/1718describe('JSMockLoader', function() {19var JSMockLoader = require('../lib/loader/JSMockLoader');20var path = require('path');21var loadResouce = require('../lib/test_helpers/loadResource');2223it('should match package.json paths', function() {24var loader = new JSMockLoader();25expect(loader.matchPath('x.js')).toBe(false);26expect(loader.matchPath('a/__mocks__/x.js')).toBe(true);27expect(loader.matchPath('__mocks__/x.js')).toBe(true);28expect(loader.matchPath('a/__mocks__/support/x.js')).toBe(false);29expect(loader.matchPath('a/1.css')).toBe(false);30});3132it('should match package.json paths with matchSubDirs', function() {33var loader = new JSMockLoader({ matchSubDirs: true });34expect(loader.matchPath('x.js')).toBe(false);35expect(loader.matchPath('a/__mocks__/x.js')).toBe(true);36expect(loader.matchPath('__mocks__/x.js')).toBe(true);37expect(loader.matchPath('a/__mocks__/support/x.js')).toBe(true);38expect(loader.matchPath('a/1.css')).toBe(false);39});4041var testData = path.join(__dirname, '..', '__test_data__', 'JSMock');4243it('should extract dependencies', function() {44loadResouce(45new JSMockLoader(),46path.join(testData, '__mocks__', 'mock.js'),47null,48function(errors, resource) {49expect(resource.id).toBe('mock');50expect(resource.requiredModules).toEqual(['foo', 'bar']);51});52});5354});555657