'use strict'; var _Exp; function _load_Exp() { return _Exp = _interopRequireWildcard(require('../Exp')); } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } jest.mock('fs'); const fs = require('fs'); const mockfs = require('mock-fs'); describe('determineEntryPointAsync', () => { beforeEach(() => { const packageJson = JSON.stringify({ name: 'testing123', version: '0.1.0', main: 'index.js' }, null, 2); const packageJsonAndroid = JSON.stringify({ name: 'testing123android', version: '0.1.0', main: 'index.android.js' }, null, 2); const packageJsonIos = JSON.stringify({ name: 'testing123ios', version: '0.1.0', main: 'index.ios.js' }, null, 2); const packageJsonNoMain = JSON.stringify({ name: 'testing456', version: '0.2.0' }); const expJson = JSON.stringify({ name: 'testing 123', version: '0.1.0', slug: 'testing-123' }, null, 2); const expJsonWithEntry = JSON.stringify({ name: 'testing567', version: '0.6.0', entryPoint: 'main.js' }); fs.__configureFs({ '/exists-no-platform/package.json': packageJson, '/exists-no-platform/exp.json': expJson, '/exists-no-platform/index.js': 'console.log("lol")', '/exists-no-platform-no-main/package.json': packageJsonNoMain, '/exists-no-platform-no-main/exp.json': expJson, '/exists-no-platform-no-main/index.js': 'console.log("lol")', '/exists-android/package.json': packageJsonAndroid, '/exists-android/exp.json': expJson, '/exists-android/index.android.js': 'console.log("lol")', '/exists-ios/package.json': packageJsonIos, '/exists-ios/exp.json': expJson, '/exists-ios/index.ios.js': 'console.log("lol")', '/exists-expjson/package.json': packageJson, '/exists-expjson/exp.json': expJsonWithEntry, '/exists-expjson/main.js': 'console.log("lol")' }); }); afterEach(() => { mockfs.restore(); }); it('exists-no-platform', _asyncToGenerator(function* () { const entryPoint = yield (_Exp || _load_Exp()).determineEntryPointAsync('/exists-no-platform'); expect(entryPoint).toBe('index.js'); })); it('exists-no-platform-no-main', _asyncToGenerator(function* () { const entryPoint = yield (_Exp || _load_Exp()).determineEntryPointAsync('/exists-no-platform-no-main'); expect(entryPoint).toBe('index.js'); })); it('exists-android', _asyncToGenerator(function* () { const entryPoint = yield (_Exp || _load_Exp()).determineEntryPointAsync('/exists-android'); expect(entryPoint).toBe('index.android.js'); })); it('exists-ios', _asyncToGenerator(function* () { const entryPoint = yield (_Exp || _load_Exp()).determineEntryPointAsync('/exists-ios'); expect(entryPoint).toBe('index.ios.js'); })); it('exists-expjson', _asyncToGenerator(function* () { const entryPoint = yield (_Exp || _load_Exp()).determineEntryPointAsync('/exists-expjson'); expect(entryPoint).toBe('main.js'); })); }); //# sourceMappingURL=../__sourcemaps__/__tests__/Exp-test.js.map