forked from observablehq/plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlegend-test.js
More file actions
25 lines (21 loc) · 1.04 KB
/
legend-test.js
File metadata and controls
25 lines (21 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as Plot from "@observablehq/plot";
import * as assert from "assert";
import it from "./jsdom.js";
it(`Plot.legend({color: {type: "identity"}}) returns undefined`, () => {
assert.strictEqual(Plot.legend({color: {type: "identity"}}), undefined);
});
it(`Plot.legend({legend: "swatches", color: {type: "<not-ordinal>"}}) throws an error`, () => {
assert.throws(() => Plot.legend({legend: "swatches", color: {type: "linear"}}), /swatches legend requires ordinal/);
assert.throws(() => Plot.legend({legend: "swatches", color: {type: "linear"}}), /\(not linear\)/);
assert.throws(
() => Plot.legend({legend: "swatches", color: {type: "diverging"}}),
/swatches legend requires ordinal/
);
assert.throws(() => Plot.legend({legend: "swatches", color: {type: "diverging"}}), /\(not diverging\)/);
});
it("Plot.legend({}) throws an error", () => {
assert.throws(() => Plot.legend({}), /unknown legend type/);
});
it("Plot.legend({color: {}}) throws an error", () => {
assert.throws(() => Plot.legend({color: {}}), /unknown legend type/);
});