Skip to content

Commit

Permalink
add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Aug 23, 2023
1 parent 4c5496c commit 1062c30
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/transforms/stack-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as Plot from "@observablehq/plot";
import assert from "assert";

it("stackY(options) returns the expected values", () => {
const y = [1, 2, -2, -1];
const {
channels: {
y1: {value: Y1},
y2: {value: Y2}
}
} = (Plot.barY(y, Plot.stackY({y})) as any).initialize();
assert.deepStrictEqual(y, [1, 2, -2, -1]);
assert.deepStrictEqual(Y1, Float64Array.of(0, 1, 0, -2));
assert.deepStrictEqual(Y2, Float64Array.of(1, 3, -2, -3));
});

it("stackY({order}) rejects an invalid order", () => {
assert.throws(() => Plot.barY([], {y: 1, order: 42 as any}), /^Error: invalid order: 42$/);
});

0 comments on commit 1062c30

Please sign in to comment.