-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathdocument-test.js
More file actions
60 lines (52 loc) · 2.33 KB
/
document-test.js
File metadata and controls
60 lines (52 loc) · 2.33 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {assert, it} from "vitest";
import * as Plot from "@observablehq/plot";
import {JSDOM} from "jsdom";
it("Plot.plot supports the document option", () => {
const {window} = new JSDOM("");
const svg = Plot.plot({document: window.document, marks: [Plot.barY([1, 2, 4, 3])]});
assert.strictEqual(svg.ownerDocument, window.document);
});
it("Plot.plot supports the document option for inline legends", () => {
const {window} = new JSDOM("");
const figure = Plot.plot({document: window.document, color: {legend: true}, marks: [Plot.cellX([1, 2, 4, 3])]});
assert.strictEqual(figure.ownerDocument, window.document);
});
it("mark.plot supports the document option", () => {
const {window} = new JSDOM("");
const svg = Plot.barY([1, 2, 4, 3]).plot({document: window.document});
assert.strictEqual(svg.ownerDocument, window.document);
});
it("Plot.legend supports the document option", () => {
const {window} = new JSDOM("");
const svg = Plot.legend({document: window.document, color: {type: "linear"}});
assert.strictEqual(svg.ownerDocument, window.document);
});
it("plot.legend supports the document option for quantitative color scales", () => {
const {window: window1} = new JSDOM("");
const {window: window2} = new JSDOM("");
const svg = Plot.plot({document: window1.document, marks: [Plot.cellX([1, 2, 4, 3])]}).legend("color", {
document: window2.document
});
assert.strictEqual(svg.ownerDocument, window2.document);
});
it("plot.legend inherits the document option", () => {
const {window} = new JSDOM("");
const svg = Plot.plot({document: window.document, marks: [Plot.cellX([1, 2, 4, 3])]}).legend("color");
assert.strictEqual(svg.ownerDocument, window.document);
});
it("plot.legend inherits the document option if that option is present but undefined", () => {
const {window} = new JSDOM("");
const svg = Plot.plot({document: window.document, marks: [Plot.cellX([1, 2, 4, 3])]}).legend("color", {
document: undefined
});
assert.strictEqual(svg.ownerDocument, window.document);
});
it("plot.legend supports the document option for categorical color scales", () => {
const {window} = new JSDOM("");
const svg = Plot.plot({
document: window.document,
color: {type: "categorical"},
marks: [Plot.cellX([1, 2, 4, 3])]
}).legend("color");
assert.strictEqual(svg.ownerDocument, window.document);
});