react / wstein / node_modules / jest-cli / node_modules / node-haste / __tests__ / FileFinder-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("FileFinder", function() {19var path = require('path');20var finder = require('../lib/FileFinder');2122var workingDir = path.join(__dirname, '..', '__test_data__', 'FileFinder');2324it("should find files in a directory using FileFinder object", function() {25var result,2627find = new finder({28scanDirs: [workingDir],29extensions: ['.js'],30useNative: true,31ignore: null32});3334runs(function() {35find.find(function(files) {36result = files;37});38});3940waitsFor(function() {41return result;42}, 300);4344runs(function() {45var files = result.map(function(r) {46return r[0];47});48expect(files.join('\n')).toContain(path.join('sub','1.js'));49expect(files.join('\n')).toContain(path.join('sub','2.js'));50expect(files.join('\n')).toContain('3.js');51});52});5354it("should find files in a directory", function() {55var result;56runs(function() {57finder.find([workingDir], ['.js'], null, function(files) {58result = files;59});60});6162waitsFor(function() {63return result;64}, 300);6566runs(function() {67var files = result.map(function(r) {68return r[0];69});70expect(files.join('\n')).toContain(path.join('sub','1.js'));71expect(files.join('\n')).toContain(path.join('sub','2.js'));72expect(files.join('\n')).toContain('3.js');73});74});7576it("should find files in a directory using native find", function() {77var result;78runs(function() {79finder.findNative([workingDir], ['.js'], null, function(files) {80result = files;81});82});8384waitsFor(function() {85return result;86}, 300);8788runs(function() {89var files = result.map(function(r) {90return r[0];91});92expect(files.join('\n')).toContain(path.join('sub','2.js'));93expect(files.join('\n')).toContain(path.join('sub','2.js'));94expect(files.join('\n')).toContain('3.js');95});96});97});9899100