Skip to content

Commit fe0de75

Browse files
committed
add missing test
1 parent 49cedcf commit fe0de75

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/transforms/stack-test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as Plot from "@observablehq/plot";
2+
import assert from "assert";
3+
4+
it("stackY(options) returns the expected values", () => {
5+
const y = [1, 2, -2, -1];
6+
const {
7+
channels: {
8+
y1: {value: Y1},
9+
y2: {value: Y2}
10+
}
11+
} = (Plot.barY(y, Plot.stackY({y})) as any).initialize();
12+
assert.deepStrictEqual(y, [1, 2, -2, -1]);
13+
assert.deepStrictEqual(Y1, Float64Array.of(0, 1, 0, -2));
14+
assert.deepStrictEqual(Y2, Float64Array.of(1, 3, -2, -3));
15+
});
16+
17+
it("stackY({order}) rejects an invalid order", () => {
18+
assert.throws(() => Plot.barY([], {y: 1, order: 42 as any}), /^Error: invalid order: 42$/);
19+
});

0 commit comments

Comments
 (0)