mirror of
https://github.com/status-im/react-native.git
synced 2025-02-24 23:28:12 +00:00
Update all tests to use Jasmine 2
Reviewed By: vjeux Differential Revision: D2782581 fb-gh-sync-id: 1d938a2bbdd8670c917c1793234dfdcb29fd4511
This commit is contained in:
parent
43ca8a0da4
commit
b7e939b38d
@ -17,6 +17,10 @@ function degreesToRadians(degrees) {
|
||||
return degrees * Math.PI / 180;
|
||||
}
|
||||
|
||||
function convertZeroes(degrees) {
|
||||
return degrees.map(value => value === -0 ? 0 : value);
|
||||
}
|
||||
|
||||
describe('MatrixMath', () => {
|
||||
|
||||
it('decomposes a 4x4 matrix to produce accurate Z-axis angles', () => {
|
||||
@ -26,11 +30,11 @@ describe('MatrixMath', () => {
|
||||
|
||||
[30, 45, 60, 75, 90, 100, 115, 120, 133, 167].forEach(angle => {
|
||||
var mat = MatrixMath.createRotateZ(degreesToRadians(angle));
|
||||
expect(MatrixMath.decomposeMatrix(mat).rotationDegrees)
|
||||
expect(convertZeroes(MatrixMath.decomposeMatrix(mat).rotationDegrees))
|
||||
.toEqual([0, 0, angle]);
|
||||
|
||||
mat = MatrixMath.createRotateZ(degreesToRadians(-angle));
|
||||
expect(MatrixMath.decomposeMatrix(mat).rotationDegrees)
|
||||
expect(convertZeroes(MatrixMath.decomposeMatrix(mat).rotationDegrees))
|
||||
.toEqual([0, 0, -angle]);
|
||||
});
|
||||
|
||||
@ -51,7 +55,7 @@ describe('MatrixMath', () => {
|
||||
// 360 is expressed as 0
|
||||
expect(MatrixMath.decomposeMatrix(
|
||||
MatrixMath.createRotateZ(degreesToRadians(360))
|
||||
).rotationDegrees).toEqual([0, 0, 0]);
|
||||
).rotationDegrees).toEqual([0, 0, -0]);
|
||||
|
||||
expect(MatrixMath.decomposeMatrix(
|
||||
MatrixMath.createRotateZ(degreesToRadians(33.33333333))
|
||||
@ -83,12 +87,12 @@ describe('MatrixMath', () => {
|
||||
[30, 45, 60, 75, 90, 100, 110, 120, 133, 167].forEach(angle => {
|
||||
mat = MatrixMath.createIdentityMatrix();
|
||||
MatrixMath.reuseRotateYCommand(mat, degreesToRadians(angle));
|
||||
expect(MatrixMath.decomposeMatrix(mat).rotationDegrees)
|
||||
expect(convertZeroes(MatrixMath.decomposeMatrix(mat).rotationDegrees))
|
||||
.toEqual([0, angle, 0]);
|
||||
|
||||
mat = MatrixMath.createIdentityMatrix();
|
||||
MatrixMath.reuseRotateYCommand(mat, degreesToRadians(-angle));
|
||||
expect(MatrixMath.decomposeMatrix(mat).rotationDegrees)
|
||||
expect(convertZeroes(MatrixMath.decomposeMatrix(mat).rotationDegrees))
|
||||
.toEqual([0, -angle, 0]);
|
||||
});
|
||||
|
||||
@ -115,7 +119,7 @@ describe('MatrixMath', () => {
|
||||
[30, 45, 60, 75, 90, 100, 110, 120, 133, 167].forEach(angle => {
|
||||
mat = MatrixMath.createIdentityMatrix();
|
||||
MatrixMath.reuseRotateXCommand(mat, degreesToRadians(angle));
|
||||
expect(MatrixMath.decomposeMatrix(mat).rotationDegrees)
|
||||
expect(convertZeroes(MatrixMath.decomposeMatrix(mat).rotationDegrees))
|
||||
.toEqual([angle, 0, 0]);
|
||||
});
|
||||
|
||||
|
@ -55,15 +55,15 @@ describe('MessageQueue', () => {
|
||||
});
|
||||
|
||||
it('should call a local function with id', () => {
|
||||
expect(TestModule.testHook1.callCount).toEqual(0);
|
||||
expect(TestModule.testHook1.calls.count()).toEqual(0);
|
||||
queue.__callFunction(0, 0, [1]);
|
||||
expect(TestModule.testHook1.callCount).toEqual(1);
|
||||
expect(TestModule.testHook1.calls.count()).toEqual(1);
|
||||
});
|
||||
|
||||
it('should call a local function with the function name', () => {
|
||||
expect(TestModule.testHook2.callCount).toEqual(0);
|
||||
expect(TestModule.testHook2.calls.count()).toEqual(0);
|
||||
queue.__callFunction('one', 'testHook2', [2]);
|
||||
expect(TestModule.testHook2.callCount).toEqual(1);
|
||||
expect(TestModule.testHook2.calls.count()).toEqual(1);
|
||||
});
|
||||
|
||||
it('should generate native modules', () => {
|
||||
@ -78,7 +78,7 @@ describe('MessageQueue', () => {
|
||||
assertQueue(flushedQueue, 0, 0, 1, ['foo', 0, 1]);
|
||||
});
|
||||
|
||||
it('should call the stored callback', (done) => {
|
||||
it('should call the stored callback', () => {
|
||||
var done = false;
|
||||
queue.RemoteModules.one.remoteMethod1(() => { done = true; });
|
||||
queue.__invokeCallback(1);
|
||||
|
@ -17,6 +17,7 @@
|
||||
"^image![a-zA-Z0-9$_-]+$": "GlobalImageStub",
|
||||
"^[./a-zA-Z0-9$_-]+\\.png$": "RelativeImageStub"
|
||||
},
|
||||
"testRunner": "<rootDir>/node_modules/jest-cli/src/testRunners/jasmine/jasmine2.js",
|
||||
"testPathIgnorePatterns": [
|
||||
"/node_modules/"
|
||||
],
|
||||
|
@ -34,8 +34,7 @@ describe('loadBundles', () => {
|
||||
|
||||
pit('shouldn\'t request already loaded bundles', () => {
|
||||
loadBundles.mockImpl((bundles, callback) => callback());
|
||||
return global
|
||||
.__loadBundles(['bundle.0'])
|
||||
return global.__loadBundles(['bundle.0'])
|
||||
.then(() => global.__loadBundles(['bundle.0']))
|
||||
.then(() => expect(loadBundlesCalls.length).toBe(1));
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* eslint global-strict:0 */
|
||||
(global => {
|
||||
let loadBundlesOnNative = (bundles) =>
|
||||
new Promise((_, resolve) =>
|
||||
new Promise((resolve) =>
|
||||
require('NativeModules').RCTBundlesLoader.loadBundles(bundles, resolve));
|
||||
|
||||
let requestedBundles = Object.create(null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user