Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('LinearInterpolator#constructor', t => {
let interpolator = new LinearInterpolator();
t.ok(interpolator, 'constructor does not throw error');
t.deepEqual(
interpolator.propNames,
['longitude', 'latitude', 'zoom', 'bearing', 'pitch'],
'propNames is set'
);
interpolator = new LinearInterpolator(['width', 'height']);
t.deepEqual(interpolator.propNames, ['width', 'height'], 'propNames is set');
interpolator = new LinearInterpolator({around: [0, 0]});
t.deepEqual(
interpolator.propNames,
['longitude', 'latitude', 'zoom', 'bearing', 'pitch'],
'propNames is set'
);
test('LinearInterpolator#constructor', t => {
let interpolator = new LinearInterpolator();
t.ok(interpolator, 'constructor does not throw error');
t.deepEqual(
interpolator.propNames,
['longitude', 'latitude', 'zoom', 'bearing', 'pitch'],
'propNames is set'
);
interpolator = new LinearInterpolator(['width', 'height']);
t.deepEqual(interpolator.propNames, ['width', 'height'], 'propNames is set');
interpolator = new LinearInterpolator({around: [0, 0]});
t.deepEqual(
interpolator.propNames,
['longitude', 'latitude', 'zoom', 'bearing', 'pitch'],
'propNames is set'
);
t.deepEqual(interpolator.around, [0, 0], 'center is set');
interpolator = new LinearInterpolator({
transitionProps: ['pitch'],
around: [0, 0]
});
t.deepEqual(interpolator.propNames, ['pitch'], 'propNames is set');
t.deepEqual(interpolator.around, [0, 0], 'center is set');
test('LinearInterpolator#constructor', t => {
let interpolator = new LinearInterpolator();
t.ok(interpolator, 'constructor does not throw error');
t.deepEqual(
interpolator.propNames,
['longitude', 'latitude', 'zoom', 'bearing', 'pitch'],
'propNames is set'
);
interpolator = new LinearInterpolator(['width', 'height']);
t.deepEqual(interpolator.propNames, ['width', 'height'], 'propNames is set');
interpolator = new LinearInterpolator({around: [0, 0]});
t.deepEqual(
interpolator.propNames,
['longitude', 'latitude', 'zoom', 'bearing', 'pitch'],
'propNames is set'
);
t.deepEqual(interpolator.around, [0, 0], 'center is set');
interpolator = new LinearInterpolator({
transitionProps: ['pitch'],
around: [0, 0]
});
t.deepEqual(interpolator.propNames, ['pitch'], 'propNames is set');
t.deepEqual(interpolator.around, [0, 0], 'center is set');
t.end();
});
TEST_CASES.forEach(testCase => {
const interpolator = new LinearInterpolator(testCase.transitionProps);
const getResult = () => interpolator.initializeProps(testCase.startProps, testCase.endProps);
if (testCase.shouldThrow) {
t.throws(getResult, testCase.title);
} else {
t.deepEqual(getResult(), testCase.expect, testCase.title);
}
});
TEST_CASES.filter(testCase => testCase.transition).forEach(testCase => {
const interpolator = new LinearInterpolator(testCase.transitionProps);
Object.keys(testCase.transition).forEach(time => {
const propsInTransition = interpolator.interpolateProps(
testCase.expect.start,
testCase.expect.end,
Number(time)
);
t.deepEqual(propsInTransition, testCase.transition[time], time);
});
});