mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 21:53:30 +00:00
Extend unit test for buildStyleInterpolator
Reviewed By: vjeux Differential Revision: D5950672 fbshipit-source-id: 921ed6ae6a2b307b050c721cedd4b51e880695ae
This commit is contained in:
parent
c550f27a4e
commit
3e31038301
@ -227,7 +227,97 @@ describe('buildStyleInterpolator', function() {
|
|||||||
});
|
});
|
||||||
expect(res).toBe(false);
|
expect(res).toBe(false);
|
||||||
});
|
});
|
||||||
|
it('should handle identity', function() {
|
||||||
|
var testAnim = {
|
||||||
|
opacity: {
|
||||||
|
type: 'identity',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var interpolator = buildStyleInterpolator(testAnim);
|
||||||
|
var obj = {};
|
||||||
|
var res = interpolator(obj, 0.5);
|
||||||
|
expect(obj).toEqual({
|
||||||
|
opacity: 0.5,
|
||||||
|
});
|
||||||
|
expect(res).toBe(true);
|
||||||
|
|
||||||
|
res = interpolator(obj, 0.5);
|
||||||
|
// No change detected
|
||||||
|
expect(obj).toEqual({
|
||||||
|
opacity: 0.5,
|
||||||
|
});
|
||||||
|
expect(res).toBe(false);
|
||||||
|
});
|
||||||
|
it('should translate', function() {
|
||||||
|
var testAnim = {
|
||||||
|
transformTranslate: {
|
||||||
|
from: {x: 1, y: 10, z: 100},
|
||||||
|
to: {x: 5, y: 50, z: 500},
|
||||||
|
min: 0,
|
||||||
|
max: 4,
|
||||||
|
type: 'linear',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var interpolator = buildStyleInterpolator(testAnim);
|
||||||
|
var obj = {};
|
||||||
|
var res = interpolator(obj, 1);
|
||||||
|
expect(obj).toEqual({
|
||||||
|
transform: [{matrix: [1, 0, 0, 0,
|
||||||
|
0, 1, 0, 0,
|
||||||
|
0, 0, 1, 0,
|
||||||
|
2, 20, 200, 1]}]
|
||||||
|
});
|
||||||
|
expect(res).toBe(true);
|
||||||
|
});
|
||||||
|
it('should scale', function() {
|
||||||
|
var testAnim = {
|
||||||
|
transformScale: {
|
||||||
|
from: {x: 1, y: 10, z: 100},
|
||||||
|
to: {x: 5, y: 50, z: 500},
|
||||||
|
min: 0,
|
||||||
|
max: 4,
|
||||||
|
type: 'linear',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var interpolator = buildStyleInterpolator(testAnim);
|
||||||
|
var obj = {};
|
||||||
|
var res = interpolator(obj, 1);
|
||||||
|
expect(obj).toEqual({
|
||||||
|
transform: [{matrix: [2, 0, 0, 0,
|
||||||
|
0, 20, 0, 0,
|
||||||
|
0, 0, 200, 0,
|
||||||
|
0, 0, 0, 1]}]
|
||||||
|
});
|
||||||
|
expect(res).toBe(true);
|
||||||
|
});
|
||||||
|
it('should combine scale and translate', function() {
|
||||||
|
var testAnim = {
|
||||||
|
transformScale: {
|
||||||
|
from: {x: 1, y: 10, z: 100},
|
||||||
|
to: {x: 5, y: 50, z: 500},
|
||||||
|
min: 0,
|
||||||
|
max: 4,
|
||||||
|
type: 'linear',
|
||||||
|
},
|
||||||
|
transformTranslate: {
|
||||||
|
from: {x: 1, y: 10, z: 100},
|
||||||
|
to: {x: 5, y: 50, z: 500},
|
||||||
|
min: 0,
|
||||||
|
max: 4,
|
||||||
|
type: 'linear',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var interpolator = buildStyleInterpolator(testAnim);
|
||||||
|
var obj = {};
|
||||||
|
var res = interpolator(obj, 1);
|
||||||
|
expect(obj).toEqual({
|
||||||
|
transform: [{matrix: [2, 0, 0, 0,
|
||||||
|
0, 20, 0, 0,
|
||||||
|
0, 0, 200, 0,
|
||||||
|
4, 400, 40000, 1]}]
|
||||||
|
});
|
||||||
|
expect(res).toBe(true);
|
||||||
|
});
|
||||||
it('should step', function() {
|
it('should step', function() {
|
||||||
var testAnim = {
|
var testAnim = {
|
||||||
opacity: {
|
opacity: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user