@@ -4,20 +4,26 @@ import {JSDOM} from "jsdom";
4
4
5
5
it ( "Plot.plot supports the document option" , ( ) => {
6
6
const { window} = new JSDOM ( "" ) ;
7
+ global . navigator = window . navigator ;
7
8
const svg = Plot . plot ( { document : window . document , marks : [ Plot . barY ( [ 1 , 2 , 4 , 3 ] ) ] } ) ;
8
9
assert . strictEqual ( svg . ownerDocument , window . document ) ;
10
+ delete global . navigator ;
9
11
} ) ;
10
12
11
13
it ( "Plot.plot supports the document option for inline legends" , ( ) => {
12
14
const { window} = new JSDOM ( "" ) ;
15
+ global . navigator = window . navigator ;
13
16
const figure = Plot . plot ( { document : window . document , color : { legend : true } , marks : [ Plot . cellX ( [ 1 , 2 , 4 , 3 ] ) ] } ) ;
14
17
assert . strictEqual ( figure . ownerDocument , window . document ) ;
18
+ delete global . navigator ;
15
19
} ) ;
16
20
17
21
it ( "mark.plot supports the document option" , ( ) => {
18
22
const { window} = new JSDOM ( "" ) ;
23
+ global . navigator = window . navigator ;
19
24
const svg = Plot . barY ( [ 1 , 2 , 4 , 3 ] ) . plot ( { document : window . document } ) ;
20
25
assert . strictEqual ( svg . ownerDocument , window . document ) ;
26
+ delete global . navigator ;
21
27
} ) ;
22
28
23
29
it ( "Plot.legend supports the document option" , ( ) => {
@@ -29,32 +35,40 @@ it("Plot.legend supports the document option", () => {
29
35
it ( "plot.legend supports the document option for quantitative color scales" , ( ) => {
30
36
const { window : window1 } = new JSDOM ( "" ) ;
31
37
const { window : window2 } = new JSDOM ( "" ) ;
38
+ global . navigator = window1 . navigator ;
32
39
const svg = Plot . plot ( { document : window1 . document , marks : [ Plot . cellX ( [ 1 , 2 , 4 , 3 ] ) ] } ) . legend ( "color" , {
33
40
document : window2 . document
34
41
} ) ;
35
42
assert . strictEqual ( svg . ownerDocument , window2 . document ) ;
43
+ delete global . navigator ;
36
44
} ) ;
37
45
38
46
it ( "plot.legend inherits the document option" , ( ) => {
39
47
const { window} = new JSDOM ( "" ) ;
48
+ global . navigator = window . navigator ;
40
49
const svg = Plot . plot ( { document : window . document , marks : [ Plot . cellX ( [ 1 , 2 , 4 , 3 ] ) ] } ) . legend ( "color" ) ;
41
50
assert . strictEqual ( svg . ownerDocument , window . document ) ;
51
+ delete global . navigator ;
42
52
} ) ;
43
53
44
54
it ( "plot.legend inherits the document option if that option is present but undefined" , ( ) => {
45
55
const { window} = new JSDOM ( "" ) ;
56
+ global . navigator = window . navigator ;
46
57
const svg = Plot . plot ( { document : window . document , marks : [ Plot . cellX ( [ 1 , 2 , 4 , 3 ] ) ] } ) . legend ( "color" , {
47
58
document : undefined
48
59
} ) ;
49
60
assert . strictEqual ( svg . ownerDocument , window . document ) ;
61
+ delete global . navigator ;
50
62
} ) ;
51
63
52
64
it ( "plot.legend supports the document option for categorical color scales" , ( ) => {
53
65
const { window} = new JSDOM ( "" ) ;
66
+ global . navigator = window . navigator ;
54
67
const svg = Plot . plot ( {
55
68
document : window . document ,
56
69
color : { type : "categorical" } ,
57
70
marks : [ Plot . cellX ( [ 1 , 2 , 4 , 3 ] ) ]
58
71
} ) . legend ( "color" ) ;
59
72
assert . strictEqual ( svg . ownerDocument , window . document ) ;
73
+ delete global . navigator ;
60
74
} ) ;
0 commit comments