react / wstein / node_modules / jest-cli / src / HasteModuleLoader / __tests__ / HasteModuleLoader-getTestEnvData-test.js
80679 views/**1* Copyright (c) 2014, Facebook, Inc. All rights reserved.2*3* This source code is licensed under the BSD-style license found in the4* LICENSE file in the root directory of this source tree. An additional grant5* of patent rights can be found in the PATENTS file in the same directory.6*/7'use strict';89jest.autoMockOff();1011var path = require('path');12var q = require('q');13var utils = require('../../lib/utils');1415describe('HasteModuleLoader', function() {16var HasteModuleLoader;17var mockEnvironment;18var resourceMap;1920var config;21beforeEach(function() {22HasteModuleLoader = require('../HasteModuleLoader');23config = utils.normalizeConfig({24name: 'HasteModuleLoader-tests',25rootDir: path.resolve(__dirname, 'test_root'),26testEnvData: {someTestData: 42},27});28});2930function buildLoader() {31if (!resourceMap) {32return HasteModuleLoader.loadResourceMap(config).then(function(map) {33resourceMap = map;34return buildLoader();35});36} else {37return q(new HasteModuleLoader(config, mockEnvironment, resourceMap));38}39}4041pit('passes config data through to jest.envData', function() {42return buildLoader().then(function(loader) {43var envData = loader.requireModule(null, 'jest-runtime').getTestEnvData();44expect(envData).toEqual(config.testEnvData);45});46});4748pit('freezes jest.envData object', function() {49return buildLoader().then(function(loader) {50var envData = loader.requireModule(null, 'jest-runtime').getTestEnvData();51expect(Object.isFrozen(envData)).toBe(true);52});53});54});555657