Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80668 views
1
/**
2
* Copyright 2013 Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
* @emails [email protected] [email protected]
17
*/
18
19
describe('JSTestLoader', function() {
20
var JSTestLoader = require('../lib/loader/JSTestLoader');
21
var path = require('path');
22
var loadResouce = require('../lib/test_helpers/loadResource');
23
24
it('should match package.json paths', function() {
25
var loader = new JSTestLoader();
26
expect(loader.matchPath('x.js')).toBe(false);
27
expect(loader.matchPath('a/__tests__/x.js')).toBe(true);
28
expect(loader.matchPath('__tests__/x.js')).toBe(true);
29
expect(loader.matchPath('a/__tests__/support/x.js')).toBe(false);
30
expect(loader.matchPath('a/1.css')).toBe(false);
31
});
32
33
var testData = path.join(__dirname, '..', '__test_data__', 'JSTest');
34
35
it('should extract dependencies', function() {
36
loadResouce(
37
new JSTestLoader(),
38
path.join(testData, '__tests__', 'test-test.js'),
39
null,
40
function(errors, resource) {
41
expect(resource.id).toBe('test-test');
42
expect(resource.requiredModules)
43
.toEqual(['fs', 'temp', 'mock-modules']);
44
expect(resource.contacts)
45
.toEqual(['[email protected]', '[email protected]']);
46
});
47
});
48
49
});
50
51