+
\ No newline at end of file
diff --git a/test/output/penguinSpeciesIsland.html b/test/output/penguinSpeciesIsland.html
new file mode 100644
index 0000000000..522226d636
--- /dev/null
+++ b/test/output/penguinSpeciesIsland.html
@@ -0,0 +1,61 @@
+
+
+
BiscoeDreamTorgersen
+
+
\ No newline at end of file
diff --git a/test/plot.js b/test/plot.js
index 7c0146ae6b..ecea7de0a5 100644
--- a/test/plot.js
+++ b/test/plot.js
@@ -13,6 +13,8 @@ import * as plots from "./plots/index.js";
const {window} = new JSDOM("");
global.document = window.document;
global.Node = window.Node;
+ global.NodeList = window.NodeList;
+ global.HTMLCollection = window.HTMLCollection;
// Not fully functional, but only used to fetch data files, so should be fine?
global.fetch = async (href) => new Response(path.resolve("./test", href));
@@ -58,6 +60,8 @@ import * as plots from "./plots/index.js";
} finally {
delete global.document;
delete global.Node;
+ delete global.NodeList;
+ delete global.HTMLCollection;
delete global.fetch;
}
});
diff --git a/test/plots/athletes-height-weight-bin.js b/test/plots/athletes-height-weight-bin.js
index 96feae2271..baec777af7 100644
--- a/test/plots/athletes-height-weight-bin.js
+++ b/test/plots/athletes-height-weight-bin.js
@@ -11,7 +11,9 @@ export default async function() {
ticks: 10
},
color: {
- scheme: "YlGnBu"
+ scheme: "YlGnBu",
+ legend: true,
+ nice: true
},
marks: [
Plot.rect(athletes, Plot.bin({fill: "count"}, {x: "weight", y: "height"}))
diff --git a/test/plots/industry-unemployment-share.js b/test/plots/industry-unemployment-share.js
index cc42e17573..09c9f2f886 100644
--- a/test/plots/industry-unemployment-share.js
+++ b/test/plots/industry-unemployment-share.js
@@ -8,6 +8,10 @@ export default async function() {
grid: true,
tickFormat: "%"
},
+ color: {
+ legend: true,
+ columns: 5
+ },
marks: [
Plot.areaY(data, Plot.stackY({
x: "date",
diff --git a/test/plots/penguin-species-island.js b/test/plots/penguin-species-island.js
index a5ef2b2324..4c145e1861 100644
--- a/test/plots/penguin-species-island.js
+++ b/test/plots/penguin-species-island.js
@@ -7,6 +7,9 @@ export default async function() {
y: {
grid: true
},
+ color: {
+ legend: true
+ },
marks: [
Plot.barY(data, Plot.groupX({y: "count"}, {x: "species", fill: "island"})),
Plot.ruleY([0])
diff --git a/test/scales/legend-test.js b/test/scales/legend-test.js
new file mode 100644
index 0000000000..ddabf903d4
--- /dev/null
+++ b/test/scales/legend-test.js
@@ -0,0 +1,26 @@
+import * as Plot from "@observablehq/plot";
+import assert from "assert";
+import {JSDOM} from "jsdom";
+const {window} = new JSDOM("");
+global.document = window.document;
+global.Node = window.Node;
+
+it("legendColor shows swatches", () => {
+ const A = Plot.legendColor({ type: "diverging", domain: [-1, 1] });
+ assert.strictEqual(A.outerHTML, ``);
+});
+
+it("legendColor accepts a scale definition", () => {
+ const color = {};
+ assert(Plot.legendColor(color).outerHTML.match(/^