Skip to content

Commit 52a3726

Browse files
author
Becca Bailey
committed
Misc cleanup in victory util tests
1 parent 49968eb commit 52a3726

File tree

7 files changed

+18
-24
lines changed

7 files changed

+18
-24
lines changed

test/jest/victory-core/victory-util/axis.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Scale, Axis } from "victory-core";
21
import React from "react";
32
import { VictoryAxis } from "victory-axis";
43
import { VictoryBar } from "victory-bar";
4+
import { Axis, Scale } from "victory-core";
55

66
describe("helpers/axis", () => {
77
const getVictoryAxis = (props) => React.createElement(VictoryAxis, props);

test/jest/victory-core/victory-util/domain.test.js

-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
1-
/* eslint no-unused-expressions: 0 */
2-
/* eslint max-nested-callbacks: 0 */
31
import React from "react";
42
import { Domain, VictoryPortal } from "victory-core";
53

6-
/*
7-
createDomainFunction,
8-
formatDomain,
9-
getDomain,
10-
getDomainFromCategories,
11-
getDomainFromData,
12-
getDomainFromMinMax,
13-
getDomainFromProps,
14-
getDomainWithZero,
15-
getMaxFromProps,
16-
getMinFromProps,
17-
getSymmetricDomain
18-
*/
19-
204
describe("victory-util/domain", () => {
215
describe("createDomainFunction", () => {
226
it("returns a function equivalent to getDomain when no props are given", () => {

test/jest/victory-core/victory-util/helpers.test.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
/* eslint no-unused-expressions: 0 */
21
import { Helpers } from "victory-core";
32

43
describe("victory-util/helpers", () => {
54
describe("omit", () => {
65
const data = { x: 3, y: 2, z: 1 };
6+
77
it("removes omitted keys and preserves all others", () => {
88
const newData = Helpers.omit(data, ["x"]);
99
expect(newData.x).toBeUndefined();
1010
expect(newData.y).toEqual(2);
1111
expect(newData.z).toEqual(1);
1212
});
13+
1314
it("creates a copy of the original object", () => {
1415
const newData = Helpers.omit(data, []);
1516
newData.x = 10;
1617
expect(data.x).toEqual(3);
1718
expect(newData.x).toEqual(10);
1819
});
20+
1921
it("defaults to an empty object", () => {
2022
const newData = Helpers.omit();
2123
expect(newData).toEqual({});
2224
});
25+
2326
it("defaults to simple shallow copy", () => {
2427
const newData = Helpers.omit(data);
2528
expect(newData).toEqual(data);
@@ -30,6 +33,7 @@ describe("victory-util/helpers", () => {
3033
it("defaults to an empty object", () => {
3134
expect(Helpers.modifyProps({})).toEqual({});
3235
});
36+
3337
it("removes the theme role's style", () => {
3438
const role = "legend";
3539
const props = {
@@ -51,6 +55,7 @@ describe("victory-util/helpers", () => {
5155
modifiedProps
5256
);
5357
});
58+
5459
it("uses fallbackProps", () => {
5560
const props = { x: 2, y: 3 };
5661
const fallbackProps = { x: 12, y: 13, z: 14 };
@@ -61,10 +66,12 @@ describe("victory-util/helpers", () => {
6166

6267
describe("evaluateProp", () => {
6368
const data = { x: 3, y: 2 };
69+
6470
it("evaluates functional props", () => {
6571
const testProp = (datum) => (datum.y > 0 ? "red" : "blue");
6672
expect(Helpers.evaluateProp(testProp, data)).toEqual("red");
6773
});
74+
6875
it("doesn't alter non-functional props", () => {
6976
const testProp = "blue";
7077
expect(Helpers.evaluateProp(testProp, data)).toEqual("blue");
@@ -73,6 +80,7 @@ describe("victory-util/helpers", () => {
7380

7481
describe("evaluateStyle", () => {
7582
const data = { x: 3, y: 2 };
83+
7684
it("evaluates functional styles, without altering others", () => {
7785
const style = {
7886
color: (datum) => (datum.y > 0 ? "red" : "blue"),
@@ -83,6 +91,7 @@ describe("victory-util/helpers", () => {
8391
size: 5
8492
});
8593
});
94+
8695
it("returns no styles if disableInlineStyles is true", () => {
8796
const style = {
8897
color: "blue"
@@ -100,6 +109,7 @@ describe("victory-util/helpers", () => {
100109
height: 200,
101110
padding: 0
102111
};
112+
103113
it("returns a range based on props and axis", () => {
104114
const x = Helpers.getRange(props, "x");
105115
expect(Array.isArray(x)).toBe(true);
@@ -119,6 +129,7 @@ describe("victory-util/helpers", () => {
119129
data: { fill: "blue", stroke: "black" },
120130
labels: { fontSize: 10, fontFamily: "Helvetica" }
121131
};
132+
122133
it("merges styles", () => {
123134
const style = { data: { fill: "red" }, labels: { fontSize: 12 } };
124135
const styles = Helpers.getStyles(style, defaultStyles);
@@ -145,12 +156,14 @@ describe("victory-util/helpers", () => {
145156
right: 40
146157
});
147158
});
159+
148160
it("sets padding from a complete object", () => {
149161
const props = {
150162
padding: { top: 20, bottom: 40, left: 60, right: 80 }
151163
};
152164
expect(Helpers.getPadding(props)).toEqual(props.padding);
153165
});
166+
154167
it("fills missing values with 0", () => {
155168
const props = {
156169
padding: { top: 40, bottom: 40 }

test/jest/victory-core/victory-util/label-helpers.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint max-nested-callbacks: 0 */
2-
3-
import { LabelHelpers, VictoryLabel } from "victory-core";
42
import { assign } from "lodash";
53
import React from "react";
4+
import { LabelHelpers, VictoryLabel } from "victory-core";
65
import * as d3Scale from "victory-vendor/d3-scale";
76

87
const scale = { x: d3Scale.scaleLinear(), y: d3Scale.scaleLinear() };

test/jest/victory-core/victory-util/scale.test.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable max-nested-callbacks */
2-
32
import { Scale } from "victory-core";
43
import * as d3Scale from "victory-vendor/d3-scale";
54

test/jest/victory-core/victory-util/transitions.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Transitions } from "victory-core";
21
import React from "react";
2+
import { Transitions } from "victory-core";
33

44
describe("getInitialTransitionState", () => {
55
const makeChild = (data) => {

test/jest/victory-core/victory-util/wrapper.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* eslint-disable no-unused-expressions,react/no-multi-comp */
2-
import { Wrapper } from "victory-core";
31
import React from "react";
42
import { VictoryAxis } from "victory-axis";
3+
import { Wrapper } from "victory-core";
54
import { VictoryLine } from "victory-line";
65

76
describe("helpers/wrapper", () => {

0 commit comments

Comments
 (0)