react-map-gl/test/utils/transition/transition-interpolator.spec.js
Xiaoji Chen 8c4128b65f
Port TransitionManager from dekc.gl (#411)
* Port TransitionManager from dekc.gl

* transition tests

* rename ViewportFlyToInterpolator to FlyToInterpolator

* export interpolation utils as non-experimental
2017-11-29 10:37:22 -08:00

42 lines
1.1 KiB
JavaScript

import test from 'tape-catch';
import {TransitionInterpolator} from '../../../src/utils/transition';
const TEST_CASES = [
{
title: 'no valid prop changes',
props: {width: 100, height: 100},
nextProps: {width: 200, height: 200},
expect: true
}, {
title: 'prop changes',
propNames: ['width', 'height'],
props: {width: 100, height: 100},
nextProps: {width: 200, height: 200},
expect: false
}, {
title: 'no valid prop changes',
propNames: ['width', 'height'],
props: {width: 100, height: 100, rotation: 0},
nextProps: {width: 100, height: 100, rotation: 30},
expect: true
}, {
title: 'array prop changes',
propNames: ['position'],
props: {position: [0, 0, 0]},
nextProps: {position: [0, 0, 0]},
expect: true
}
];
test('TransitionInterpolator#arePropsEqual', t => {
TEST_CASES.forEach(testCase => {
const interpolator = new TransitionInterpolator();
interpolator.propNames = testCase.propNames;
t.is(interpolator.arePropsEqual(testCase.props, testCase.nextProps),
testCase.expect, testCase.title);
});
t.end();
});