|
1 | | -var tape = require("tape"), |
2 | | - interpolate = require("../"); |
| 1 | +import assert from "assert"; |
| 2 | +import {interpolateArray} from "../src/index.js"; |
3 | 3 |
|
4 | | -tape("interpolateArray(a, b) interpolates defined elements in a and b", function(test) { |
5 | | - test.deepEqual(interpolate.interpolateArray([2, 12], [4, 24])(0.5), [3, 18]); |
6 | | - test.end(); |
| 4 | +it("interpolateArray(a, b) interpolates defined elements in a and b", () => { |
| 5 | + assert.deepStrictEqual(interpolateArray([2, 12], [4, 24])(0.5), [3, 18]); |
7 | 6 | }); |
8 | 7 |
|
9 | | -tape("interpolateArray(a, b) interpolates nested objects and arrays", function(test) { |
10 | | - test.deepEqual(interpolate.interpolateArray([[2, 12]], [[4, 24]])(0.5), [[3, 18]]); |
11 | | - test.deepEqual(interpolate.interpolateArray([{foo: [2, 12]}], [{foo: [4, 24]}])(0.5), [{foo: [3, 18]}]); |
12 | | - test.end(); |
| 8 | +it("interpolateArray(a, b) interpolates nested objects and arrays", () => { |
| 9 | + assert.deepStrictEqual(interpolateArray([[2, 12]], [[4, 24]])(0.5), [[3, 18]]); |
| 10 | + assert.deepStrictEqual(interpolateArray([{foo: [2, 12]}], [{foo: [4, 24]}])(0.5), [{foo: [3, 18]}]); |
13 | 11 | }); |
14 | 12 |
|
15 | | -tape("interpolateArray(a, b) ignores elements in a that are not in b", function(test) { |
16 | | - test.deepEqual(interpolate.interpolateArray([2, 12, 12], [4, 24])(0.5), [3, 18]); |
17 | | - test.end(); |
| 13 | +it("interpolateArray(a, b) ignores elements in a that are not in b", () => { |
| 14 | + assert.deepStrictEqual(interpolateArray([2, 12, 12], [4, 24])(0.5), [3, 18]); |
18 | 15 | }); |
19 | 16 |
|
20 | | -tape("interpolateArray(a, b) uses constant elements in b that are not in a", function(test) { |
21 | | - test.deepEqual(interpolate.interpolateArray([2, 12], [4, 24, 12])(0.5), [3, 18, 12]); |
22 | | - test.end(); |
| 17 | +it("interpolateArray(a, b) uses constant elements in b that are not in a", () => { |
| 18 | + assert.deepStrictEqual(interpolateArray([2, 12], [4, 24, 12])(0.5), [3, 18, 12]); |
23 | 19 | }); |
24 | 20 |
|
25 | | -tape("interpolateArray(a, b) treats undefined as an empty array", function(test) { |
26 | | - test.deepEqual(interpolate.interpolateArray(undefined, [2, 12])(0.5), [2, 12]); |
27 | | - test.deepEqual(interpolate.interpolateArray([2, 12], undefined)(0.5), []); |
28 | | - test.deepEqual(interpolate.interpolateArray(undefined, undefined)(0.5), []); |
29 | | - test.end(); |
| 21 | +it("interpolateArray(a, b) treats undefined as an empty array", () => { |
| 22 | + assert.deepStrictEqual(interpolateArray(undefined, [2, 12])(0.5), [2, 12]); |
| 23 | + assert.deepStrictEqual(interpolateArray([2, 12], undefined)(0.5), []); |
| 24 | + assert.deepStrictEqual(interpolateArray(undefined, undefined)(0.5), []); |
30 | 25 | }); |
31 | 26 |
|
32 | | -tape("interpolateArray(a, b) interpolates array-like objects", function(test) { |
33 | | - var array = new Float64Array(2), |
34 | | - args = (function() { return arguments; })(2, 12); |
| 27 | +it("interpolateArray(a, b) interpolates array-like objects", () => { |
| 28 | + const array = new Float64Array(2); |
| 29 | + const args = (function() { return arguments; })(2, 12); |
35 | 30 | array[0] = 2; |
36 | 31 | array[1] = 12; |
37 | | - test.deepEqual(interpolate.interpolateArray(array, [4, 24])(0.5), [3, 18]); |
38 | | - test.deepEqual(interpolate.interpolateArray(args, [4, 24])(0.5), [3, 18]); |
39 | | - test.end(); |
| 32 | + assert.deepStrictEqual(interpolateArray(array, [4, 24])(0.5), [3, 18]); |
| 33 | + assert.deepStrictEqual(interpolateArray(args, [4, 24])(0.5), [3, 18]); |
40 | 34 | }); |
41 | 35 |
|
42 | | -tape("interpolateArray(a, b) gives exact ends for t=0 and t=1", function(test) { |
43 | | - var a = [2e+42], b = [335]; |
44 | | - test.deepEqual(interpolate.interpolateArray(a, b)(1), b); |
45 | | - test.deepEqual(interpolate.interpolateArray(a, b)(0), a); |
46 | | - test.end(); |
| 36 | +it("interpolateArray(a, b) gives exact ends for t=0 and t=1", () => { |
| 37 | + const a = [2e+42], b = [335]; |
| 38 | + assert.deepStrictEqual(interpolateArray(a, b)(1), b); |
| 39 | + assert.deepStrictEqual(interpolateArray(a, b)(0), a); |
47 | 40 | }); |
0 commit comments