Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80679 views
1
/**
2
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
3
*
4
* This source code is licensed under the BSD-style license found in the
5
* LICENSE file in the root directory of this source tree. An additional grant
6
* of patent rights can be found in the PATENTS file in the same directory.
7
*/
8
'use strict';
9
10
jest.autoMockOff();
11
12
var path = require('path');
13
var q = require('q');
14
var utils = require('../../lib/utils');
15
16
describe('HasteModuleLoader', function() {
17
var HasteModuleLoader;
18
var mockEnvironment;
19
var resourceMap;
20
21
var config;
22
beforeEach(function() {
23
HasteModuleLoader = require('../HasteModuleLoader');
24
config = utils.normalizeConfig({
25
name: 'HasteModuleLoader-tests',
26
rootDir: path.resolve(__dirname, 'test_root'),
27
testEnvData: {someTestData: 42},
28
});
29
});
30
31
function buildLoader() {
32
if (!resourceMap) {
33
return HasteModuleLoader.loadResourceMap(config).then(function(map) {
34
resourceMap = map;
35
return buildLoader();
36
});
37
} else {
38
return q(new HasteModuleLoader(config, mockEnvironment, resourceMap));
39
}
40
}
41
42
pit('passes config data through to jest.envData', function() {
43
return buildLoader().then(function(loader) {
44
var envData = loader.requireModule(null, 'jest-runtime').getTestEnvData();
45
expect(envData).toEqual(config.testEnvData);
46
});
47
});
48
49
pit('freezes jest.envData object', function() {
50
return buildLoader().then(function(loader) {
51
var envData = loader.requireModule(null, 'jest-runtime').getTestEnvData();
52
expect(Object.isFrozen(envData)).toBe(true);
53
});
54
});
55
});
56
57