mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-27 22:54:46 +08:00
Codemod tests to use top-level-requires
Reviewed By: @DmitrySoshnikov Differential Revision: D2456250
This commit is contained in:
committed by
facebook-github-bot-5
parent
3fca7f4d7b
commit
fa01b2e4cb
@@ -98,9 +98,10 @@ describe('Animated', () => {
|
||||
|
||||
|
||||
it('stops animation when detached', () => {
|
||||
// jest environment doesn't have requestAnimationFrame :(
|
||||
window.requestAnimationFrame = jest.genMockFunction();
|
||||
window.cancelAnimationFrame = jest.genMockFunction();
|
||||
// jest environment doesn't have cancelAnimationFrame :(
|
||||
if (!window.cancelAnimationFrame) {
|
||||
window.cancelAnimationFrame = jest.genMockFunction();
|
||||
}
|
||||
|
||||
var anim = new Animated.Value(0);
|
||||
var callback = jest.genMockFunction();
|
||||
|
||||
@@ -12,10 +12,10 @@ jest
|
||||
.dontMock('AssetRegistry')
|
||||
.dontMock('../resolveAssetSource');
|
||||
|
||||
var AssetRegistry;
|
||||
var Platform;
|
||||
var SourceCode;
|
||||
var resolveAssetSource;
|
||||
var AssetRegistry = require('AssetRegistry');
|
||||
var Platform = require('Platform');
|
||||
var NativeModules = require('NativeModules');
|
||||
var resolveAssetSource = require('../resolveAssetSource');
|
||||
|
||||
function expectResolvesAsset(input, expectedSource) {
|
||||
var assetId = AssetRegistry.registerAsset(input);
|
||||
@@ -26,10 +26,6 @@ describe('resolveAssetSource', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModuleRegistry();
|
||||
__DEV__ = true;
|
||||
AssetRegistry = require('AssetRegistry');
|
||||
Platform = require('Platform');
|
||||
SourceCode = require('NativeModules').SourceCode;
|
||||
resolveAssetSource = require('../resolveAssetSource');
|
||||
});
|
||||
|
||||
it('returns same source for simple static and network images', () => {
|
||||
@@ -64,7 +60,8 @@ describe('resolveAssetSource', () => {
|
||||
|
||||
describe('bundle was loaded from network (DEV)', () => {
|
||||
beforeEach(() => {
|
||||
SourceCode.scriptURL = 'http://10.0.0.1:8081/main.bundle';
|
||||
NativeModules.SourceCode.scriptURL =
|
||||
'http://10.0.0.1:8081/main.bundle';
|
||||
Platform.OS = 'ios';
|
||||
});
|
||||
|
||||
@@ -110,7 +107,8 @@ describe('resolveAssetSource', () => {
|
||||
|
||||
describe('bundle was loaded from file (PROD) on iOS', () => {
|
||||
beforeEach(() => {
|
||||
SourceCode.scriptURL = 'file:///Path/To/Simulator/main.bundle';
|
||||
NativeModules.SourceCode.scriptURL =
|
||||
'file:///Path/To/Simulator/main.bundle';
|
||||
__DEV__ = false;
|
||||
Platform.OS = 'ios';
|
||||
});
|
||||
@@ -137,7 +135,8 @@ describe('resolveAssetSource', () => {
|
||||
|
||||
describe('bundle was loaded from file (PROD) on Android', () => {
|
||||
beforeEach(() => {
|
||||
SourceCode.scriptURL = 'file:///Path/To/Simulator/main.bundle';
|
||||
NativeModules.SourceCode.scriptURL =
|
||||
'file:///Path/To/Simulator/main.bundle';
|
||||
__DEV__ = false;
|
||||
Platform.OS = 'android';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user