-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab589e0
commit fdb6eeb
Showing
15 changed files
with
509 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { shallow } from "enzyme"; | ||
import React from "react"; | ||
|
||
import { expect, it } from "@jest/globals"; | ||
|
||
import { BKFilter, chartConfig } from "../../../popups/timeseries/BKFilter"; | ||
|
||
describe("BKFilter", () => { | ||
let wrapper, props; | ||
|
||
beforeEach(() => { | ||
props = { | ||
baseCfg: {}, | ||
cfg: {}, | ||
updateState: jest.fn(), | ||
}; | ||
wrapper = shallow(<BKFilter {...props} />); | ||
}); | ||
|
||
it("renders successfully", () => { | ||
expect(wrapper.find("div.col-md-4")).toHaveLength(3); | ||
expect(props.updateState).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it("updates state", () => { | ||
wrapper.find("input").forEach(input => { | ||
input.simulate("change", { target: { value: 5 } }); | ||
input.simulate("keyDown", { key: "Enter" }); | ||
}); | ||
expect(props.updateState).toHaveBeenLastCalledWith({ | ||
cfg: { low: 5, high: 5, K: 5 }, | ||
}); | ||
}); | ||
|
||
it("updates state on baseCfg update", () => { | ||
props.updateState.mockReset(); | ||
wrapper.setProps({ baseCfg: { col: "foo" } }); | ||
expect(props.updateState).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it("builds chart config correctly", () => { | ||
const cfg = chartConfig( | ||
{ col: "foo" }, | ||
{ | ||
data: { datasets: [{}, {}] }, | ||
options: { | ||
scales: { | ||
"y-cycle": {}, | ||
"y-foo": {}, | ||
x: { title: { display: false } }, | ||
}, | ||
plugins: {}, | ||
}, | ||
} | ||
); | ||
expect(cfg.options.scales["y-foo"].position).toBe("left"); | ||
expect(cfg.options.scales["y-cycle"].position).toBe("right"); | ||
expect(cfg.options.plugins.legend.display).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { shallow } from "enzyme"; | ||
import React from "react"; | ||
import Select from "react-select"; | ||
|
||
import { expect, it } from "@jest/globals"; | ||
|
||
import { BaseInputs } from "../../../popups/timeseries/BaseInputs"; | ||
|
||
describe("BaseInputs", () => { | ||
let wrapper, props; | ||
|
||
beforeEach(() => { | ||
props = { | ||
columns: [{ dtype: "int", name: "foo" }], | ||
cfg: {}, | ||
updateState: jest.fn(), | ||
}; | ||
wrapper = shallow(<BaseInputs {...props} />); | ||
}); | ||
|
||
it("renders successfully", () => { | ||
expect(wrapper.find("div.col-md-4")).toHaveLength(3); | ||
}); | ||
|
||
it("updates state", () => { | ||
wrapper | ||
.find("ColumnSelect") | ||
.first() | ||
.props() | ||
.updateState({ index: { value: "date" } }); | ||
wrapper | ||
.find("ColumnSelect") | ||
.last() | ||
.props() | ||
.updateState({ col: { value: "foo" } }); | ||
wrapper.find(Select).props().onChange({ value: "sum" }); | ||
expect(props.updateState).toHaveBeenLastCalledWith({ | ||
index: "date", | ||
col: "foo", | ||
agg: "sum", | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { shallow } from "enzyme"; | ||
import React from "react"; | ||
|
||
import { expect, it } from "@jest/globals"; | ||
|
||
import { CFFilter, chartConfig } from "../../../popups/timeseries/CFFilter"; | ||
|
||
describe("CFFilter", () => { | ||
let wrapper, props; | ||
|
||
beforeEach(() => { | ||
props = { | ||
baseCfg: {}, | ||
cfg: {}, | ||
updateState: jest.fn(), | ||
}; | ||
wrapper = shallow(<CFFilter {...props} />); | ||
}); | ||
|
||
it("renders successfully", () => { | ||
expect(wrapper.find("div.col-md-4")).toHaveLength(3); | ||
expect(props.updateState).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it("updates state", () => { | ||
wrapper.find("input").forEach(input => { | ||
input.simulate("change", { target: { value: 5 } }); | ||
input.simulate("keyDown", { key: "Enter" }); | ||
}); | ||
wrapper.find("i").simulate("click"); | ||
expect(props.updateState).toHaveBeenLastCalledWith({ | ||
cfg: { low: 5, high: 5, drift: true }, | ||
}); | ||
}); | ||
|
||
it("updates state on baseCfg update", () => { | ||
props.updateState.mockReset(); | ||
wrapper.setProps({ baseCfg: { col: "foo" } }); | ||
expect(props.updateState).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it("builds chart config correctly", () => { | ||
const cfg = chartConfig( | ||
{ col: "foo" }, | ||
{ | ||
data: { datasets: [{}, {}, {}] }, | ||
options: { | ||
scales: { | ||
"y-cycle": {}, | ||
"y-trend": {}, | ||
"y-foo": { title: {} }, | ||
x: { title: { display: false } }, | ||
}, | ||
plugins: {}, | ||
}, | ||
} | ||
); | ||
expect(cfg.options.scales["y-foo"].position).toBe("left"); | ||
expect(cfg.options.scales["y-foo"].title.text).toBe("foo, trend"); | ||
expect(cfg.options.scales["y-cycle"].position).toBe("right"); | ||
expect(cfg.options.scales["y-trend"].display).toBe(false); | ||
expect(cfg.options.plugins.legend.display).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.