-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathline-test.js
More file actions
116 lines (103 loc) · 3.88 KB
/
Copy pathline-test.js
File metadata and controls
116 lines (103 loc) · 3.88 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import * as Plot from "@observablehq/plot";
import {curveStep} from "d3";
import assert from "assert";
it("line() has the expected defaults", () => {
const line = Plot.line();
assert.strictEqual(line.data, undefined);
assert.strictEqual(line.transform, undefined);
assert.deepStrictEqual(Object.keys(line.channels), ["x", "y"]);
assert.deepStrictEqual(
Object.values(line.channels).map((c) =>
Plot.valueof(
[
[1, 2],
[3, 4]
],
c.value
)
),
[
[1, 3],
[2, 4]
]
);
assert.deepStrictEqual(
Object.values(line.channels).map((c) => c.scale),
["x", "y"]
);
assert.strictEqual(line.curve.name, "curveAuto");
assert.strictEqual(line.fill, "none");
assert.strictEqual(line.fillOpacity, undefined);
assert.strictEqual(line.stroke, "currentColor");
assert.strictEqual(line.strokeWidth, 1.5);
assert.strictEqual(line.strokeOpacity, undefined);
assert.strictEqual(line.strokeLinejoin, "round");
assert.strictEqual(line.strokeLinecap, "round");
assert.strictEqual(line.strokeMiterlimit, undefined);
assert.strictEqual(line.strokeDasharray, undefined);
assert.strictEqual(line.strokeDashoffset, undefined);
assert.strictEqual(line.mixBlendMode, undefined);
assert.strictEqual(line.shapeRendering, undefined);
});
it("line(data, {z}) specifies an optional z channel", () => {
const line = Plot.line(undefined, {z: "2"});
const {z} = line.channels;
assert.strictEqual(z.value, "2");
assert.strictEqual(z.scale, undefined);
});
it("line(data, {title}) specifies an optional title channel", () => {
const line = Plot.line(undefined, {title: "2"});
const {title} = line.channels;
assert.strictEqual(title.value, "2");
assert.strictEqual(title.scale, undefined);
});
it("line(data, {fill}) allows fill to be a constant color", () => {
const line = Plot.line(undefined, {fill: "red"});
assert.strictEqual(line.fill, "red");
});
it("line(data, {fill}) allows fill to be null", () => {
const line = Plot.line(undefined, {fill: null});
assert.strictEqual(line.fill, "none");
});
it("line(data, {fill}) allows fill to be a variable color", () => {
const line = Plot.line(undefined, {fill: "x"});
assert.strictEqual(line.fill, undefined);
const {fill} = line.channels;
assert.strictEqual(fill.value, "x");
assert.strictEqual(fill.scale, "auto");
});
it("line(data, {fill}) implies a default z channel if fill is variable", () => {
const line = Plot.line(undefined, {fill: "2"});
const {z} = line.channels;
assert.strictEqual(z.value, "2");
assert.strictEqual(z.scale, undefined);
});
it("line(data, {stroke}) allows stroke to be a constant color", () => {
const line = Plot.line(undefined, {stroke: "red"});
assert.strictEqual(line.stroke, "red");
});
it("line(data, {stroke}) allows stroke to be null", () => {
const line = Plot.line(undefined, {stroke: null});
assert.strictEqual(line.stroke, undefined);
});
it("line(data, {stroke}) implies no stroke width if stroke is null", () => {
const line = Plot.line(undefined, {stroke: null});
assert.strictEqual(line.strokeWidth, undefined);
});
it("line(data, {stroke}) allows stroke to be a variable color", () => {
const line = Plot.line(undefined, {stroke: "x", fill: "3"}); // stroke takes priority
assert.strictEqual(line.stroke, undefined);
const {stroke} = line.channels;
assert.strictEqual(stroke.value, "x");
assert.strictEqual(stroke.scale, "auto");
});
it("line(data, {stroke}) implies a default z channel if stroke is variable", () => {
const line = Plot.line(undefined, {stroke: "2"});
const {z} = line.channels;
assert.strictEqual(z.value, "2");
assert.strictEqual(z.scale, undefined);
});
it("line(data, {curve}) specifies a named curve or function", () => {
assert.strictEqual(Plot.line(undefined, {curve: "step"}).curve, curveStep);
assert.strictEqual(Plot.line(undefined, {curve: curveStep}).curve, curveStep);
});