react / wstein / node_modules / jest-cli / node_modules / node-haste / __tests__ / JSBenchLoader-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('JSBenchLoader', function() {19var JSBenchLoader = require('../lib/loader/JSBenchLoader');20var path = require('path');21var ProjectConfiguration = require('../lib/resource/ProjectConfiguration');22var loadResouce = require('../lib/test_helpers/loadResource');2324it('should match package.json paths', function() {25var loader = new JSBenchLoader();26expect(loader.matchPath('x.js')).toBe(false);27expect(loader.matchPath('a/__benchmarks__/x.js')).toBe(true);28expect(loader.matchPath('__benchmarks__/x.js')).toBe(true);29expect(loader.matchPath('a/__benchmarks__/support/x.js')).toBe(false);30expect(loader.matchPath('a/1.css')).toBe(false);31});3233it('should match package.json paths with matchSubDirs', function() {34var loader = new JSBenchLoader({ matchSubDirs: true });35expect(loader.matchPath('x.js')).toBe(false);36expect(loader.matchPath('a/__benchmarks__/x.js')).toBe(true);37expect(loader.matchPath('__benchmarks__/x.js')).toBe(true);38expect(loader.matchPath('a/__benchmarks__/support/x.js')).toBe(true);39expect(loader.matchPath('a/1.css')).toBe(false);40});4142var testData = path.join(__dirname, '..', '__test_data__', 'JSBench');4344it('should extract dependencies', function() {45loadResouce(46new JSBenchLoader(),47path.join(testData, '__benchmarks__/html-bench.js'),48null,49function(errors, resource) {50expect(resource.id).toBe('html-bench');51expect(resource.requiredModules)52.toEqual(['htmlSpecialChars']);53expect(resource.contacts).toEqual(['[email protected]']);54});55});5657it('should resolve paths using configuration', function() {58loadResouce(59new JSBenchLoader(),60path.join(testData, 'configured', '__benchmarks__', 'test-bench.js'),61new ProjectConfiguration(62path.join(testData, 'configured', 'package.json'),63{}),64function(errors, resource) {65expect(resource.id).toBe(path.join('configured','__benchmarks__','test-bench.js'));66});67});6869});707172