Skip to content

Commit

Permalink
let tests pass, build docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Dec 21, 2023
1 parent ceb54c3 commit 3984689
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/components/PlotRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {h, withDirectives} from "vue";
class Document {
constructor() {
this.documentElement = new Element(this, "html");
if (!globalThis.navigator) globalThis.navigator = {};
}
createElementNS(namespace, tagName) {
return new Element(this, tagName);
Expand Down
14 changes: 14 additions & 0 deletions test/document-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ import {JSDOM} from "jsdom";

it("Plot.plot supports the document option", () => {
const {window} = new JSDOM("");
global.navigator = window.navigator;
const svg = Plot.plot({document: window.document, marks: [Plot.barY([1, 2, 4, 3])]});
assert.strictEqual(svg.ownerDocument, window.document);
delete global.navigator;
});

it("Plot.plot supports the document option for inline legends", () => {
const {window} = new JSDOM("");
global.navigator = window.navigator;
const figure = Plot.plot({document: window.document, color: {legend: true}, marks: [Plot.cellX([1, 2, 4, 3])]});
assert.strictEqual(figure.ownerDocument, window.document);
delete global.navigator;
});

it("mark.plot supports the document option", () => {
const {window} = new JSDOM("");
global.navigator = window.navigator;
const svg = Plot.barY([1, 2, 4, 3]).plot({document: window.document});
assert.strictEqual(svg.ownerDocument, window.document);
delete global.navigator;
});

it("Plot.legend supports the document option", () => {
Expand All @@ -29,32 +35,40 @@ it("Plot.legend supports the document option", () => {
it("plot.legend supports the document option for quantitative color scales", () => {
const {window: window1} = new JSDOM("");
const {window: window2} = new JSDOM("");
global.navigator = window1.navigator;
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);
delete global.navigator;
});

it("plot.legend inherits the document option", () => {
const {window} = new JSDOM("");
global.navigator = window.navigator;
const svg = Plot.plot({document: window.document, marks: [Plot.cellX([1, 2, 4, 3])]}).legend("color");
assert.strictEqual(svg.ownerDocument, window.document);
delete global.navigator;
});

it("plot.legend inherits the document option if that option is present but undefined", () => {
const {window} = new JSDOM("");
global.navigator = window.navigator;
const svg = Plot.plot({document: window.document, marks: [Plot.cellX([1, 2, 4, 3])]}).legend("color", {
document: undefined
});
assert.strictEqual(svg.ownerDocument, window.document);
delete global.navigator;
});

it("plot.legend supports the document option for categorical color scales", () => {
const {window} = new JSDOM("");
global.navigator = window.navigator;
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);
delete global.navigator;
});

0 comments on commit 3984689

Please sign in to comment.