Skip to content

Commit 8fca112

Browse files
committed
fix tests
1 parent ed914e9 commit 8fca112

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

test/output/tipBoxX.svg

Lines changed: 1 addition & 1 deletion
Loading

test/pointer-test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
// @vitest-environment node
2+
13
import * as Plot from "@observablehq/plot";
2-
import assert from "assert";
34
import {JSDOM} from "jsdom";
5+
import {afterEach, assert, beforeEach, describe, it} from "vitest";
46

57
function setup() {
68
const jsdom = new JSDOM("");
@@ -49,10 +51,12 @@ function visibleTips(svg) {
4951
}
5052

5153
describe("pointer pool", () => {
54+
let pointer, flushAnimationFrame;
55+
56+
beforeEach(() => ({pointer, flushAnimationFrame} = setup()));
5257
afterEach(teardown);
5358

5459
it("multiple tip: true marks show only one tip", () => {
55-
const {pointer, flushAnimationFrame} = setup();
5660
const svg = Plot.plot({
5761
marks: [
5862
Plot.dot([{x: 1, y: 1}, {x: 2, y: 2}], {x: "x", y: "y", tip: true}), // prettier-ignore
@@ -66,7 +70,6 @@ describe("pointer pool", () => {
6670
});
6771

6872
it("compound marks with tip: true show only one tip", () => {
69-
const {pointer, flushAnimationFrame} = setup();
7073
const svg = Plot.boxX([1, 2, 3, 4, 5, 10, 20], {tip: true}).plot();
7174
const tips = svg.querySelectorAll("[aria-label=tip]");
7275
assert.ok(tips.length > 1, "boxX should create multiple tip marks");
@@ -77,7 +80,6 @@ describe("pointer pool", () => {
7780
});
7881

7982
it("crosshair renders all sub-marks (does not pool)", () => {
80-
const {pointer, flushAnimationFrame} = setup();
8183
const svg = Plot.plot({
8284
marks: [Plot.crosshair([{x: 1, y: 1}, {x: 2, y: 2}], {x: "x", y: "y"})] // prettier-ignore
8385
});
@@ -91,7 +93,6 @@ describe("pointer pool", () => {
9193
});
9294

9395
it("crosshair and tip: true coexist", () => {
94-
const {pointer, flushAnimationFrame} = setup();
9596
const svg = Plot.plot({
9697
marks: [
9798
Plot.dot([{x: 1, y: 1}, {x: 2, y: 2}], {x: "x", y: "y", tip: true}), // prettier-ignore
@@ -115,7 +116,6 @@ describe("pointer pool", () => {
115116
});
116117

117118
it("explicit tip(pointer) pools with tip: true", () => {
118-
const {pointer, flushAnimationFrame} = setup();
119119
const data = [{x: 1, y: 1}, {x: 2, y: 2}]; // prettier-ignore
120120
const svg = Plot.plot({
121121
marks: [Plot.dot(data, {x: "x", y: "y", tip: true}), Plot.tip(data, Plot.pointer({x: "x", y: "y", pool: true}))]
@@ -127,7 +127,6 @@ describe("pointer pool", () => {
127127
});
128128

129129
it("pointerleave hides all tips", () => {
130-
const {pointer, flushAnimationFrame} = setup();
131130
const svg = Plot.plot({
132131
marks: [
133132
Plot.dot([{x: 1, y: 1}, {x: 2, y: 2}], {x: "x", y: "y", tip: true}), // prettier-ignore

0 commit comments

Comments
 (0)