-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathfacet-test.js
More file actions
38 lines (33 loc) · 1.54 KB
/
facet-test.js
File metadata and controls
38 lines (33 loc) · 1.54 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
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as Plot from "@observablehq/plot";
import * as d3 from "d3";
import assert from "./assert.js";
import {it} from "vitest";
it("mark data parallel to facet data triggers a warning", async () => {
const data = await d3.csv("data/anscombe.csv", d3.autoType);
assert.warns(
() => Plot.dot(data.slice(), {x: "x", y: "y"}).plot({facet: {data, x: "series"}}),
/dot mark appears to use faceted data/
);
});
it("mark data parallel to facet data does not trigger a warning if explicitly faceted", async () => {
const data = await d3.csv("data/anscombe.csv", d3.autoType);
assert.doesNotWarn(() =>
Plot.dot(data.slice(0, 1), {x: "x", y: "y", facet: true}).plot({facet: {data, x: "series"}})
);
});
it("mark data parallel to facet data does not trigger a warning if explicitly not faceted", async () => {
const data = await d3.csv("data/anscombe.csv", d3.autoType);
assert.doesNotWarn(() =>
Plot.dot(data.slice(0, 1), {x: "x", y: "y", facet: false}).plot({facet: {data, x: "series"}})
);
});
it("mark data not parallel to facet data does not trigger a warning", async () => {
const data = await d3.csv("data/anscombe.csv", d3.autoType);
assert.doesNotWarn(() =>
Plot.dot(data.slice(0, 1), {x: "x", y: "y", facet: undefined}).plot({facet: {data, x: "series"}})
);
});
it("detects missing facet data", async () => {
assert.throws(() => Plot.barY([], {x: "x", y: "y"}).plot({facet: {x: "fx"}}), /missing facet data/);
assert.throws(() => Plot.barY([], {x: "x", y: "y"}).plot({facet: {data: null, x: "fx"}}), /missing facet data/);
});