mirror of
https://github.com/visgl/react-map-gl.git
synced 2025-12-08 20:16:02 +00:00
* Port TransitionManager from dekc.gl * transition tests * rename ViewportFlyToInterpolator to FlyToInterpolator * export interpolation utils as non-experimental
42 lines
1.1 KiB
JavaScript
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();
|
|
});
|