-
Notifications
You must be signed in to change notification settings - Fork 414
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
Andrew Schonfeld
committed
Apr 7, 2020
1 parent
d20abc1
commit 8ca032a
Showing
14 changed files
with
183 additions
and
77 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,86 @@ | ||
import { mount } from "enzyme"; | ||
import $ from "jquery"; | ||
import React from "react"; | ||
import { Provider } from "react-redux"; | ||
|
||
import mockPopsicle from "../MockPopsicle"; | ||
import * as t from "../jest-assertions"; | ||
import reduxUtils from "../redux-test-utils"; | ||
import { buildInnerHTML, withGlobalJquery } from "../test-utils"; | ||
import { clickColMenuButton } from "./iframe-utils"; | ||
|
||
const originalOffsetHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "offsetHeight"); | ||
const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "offsetWidth"); | ||
|
||
describe("DataViewer iframe tests", () => { | ||
const { post } = $; | ||
|
||
beforeAll(() => { | ||
Object.defineProperty(HTMLElement.prototype, "offsetHeight", { | ||
configurable: true, | ||
value: 500, | ||
}); | ||
Object.defineProperty(HTMLElement.prototype, "offsetWidth", { | ||
configurable: true, | ||
value: 500, | ||
}); | ||
|
||
const mockBuildLibs = withGlobalJquery(() => | ||
mockPopsicle.mock(url => { | ||
const { urlFetcher } = require("../redux-test-utils").default; | ||
return urlFetcher(url); | ||
}) | ||
); | ||
|
||
const mockChartUtils = withGlobalJquery(() => (ctx, cfg) => { | ||
const chartCfg = { ctx, cfg, data: cfg.data, destroyed: false }; | ||
chartCfg.destroy = () => (chartCfg.destroyed = true); | ||
chartCfg.getElementsAtXAxis = _evt => [{ _index: 0 }]; | ||
return chartCfg; | ||
}); | ||
|
||
jest.mock("popsicle", () => mockBuildLibs); | ||
jest.mock("chart.js", () => mockChartUtils); | ||
jest.mock("chartjs-plugin-zoom", () => ({})); | ||
jest.mock("chartjs-chart-box-and-violin-plot/build/Chart.BoxPlot.js", () => ({})); | ||
}); | ||
|
||
afterAll(() => { | ||
Object.defineProperty(HTMLElement.prototype, "offsetHeight", originalOffsetHeight); | ||
Object.defineProperty(HTMLElement.prototype, "offsetWidth", originalOffsetWidth); | ||
$.post = post; | ||
}); | ||
|
||
test("DataViewer: hiding a column", done => { | ||
const { DataViewer } = require("../../dtale/DataViewer"); | ||
|
||
const store = reduxUtils.createDtaleStore(); | ||
buildInnerHTML({ settings: "", iframe: "True" }, store); | ||
const result = mount( | ||
<Provider store={store}> | ||
<DataViewer /> | ||
</Provider>, | ||
{ | ||
attachTo: document.getElementById("content"), | ||
} | ||
); | ||
|
||
setTimeout(() => { | ||
result.update(); | ||
result | ||
.find(".main-grid div.headerCell div") | ||
.last() | ||
.simulate("click"); | ||
clickColMenuButton(result, "Delete"); | ||
setTimeout(() => { | ||
result.update(); | ||
t.deepEqual( | ||
result.find(".main-grid div.headerCell").map(hc => hc.text()), | ||
["col1", "col2", "col3"], | ||
"should render column headers" | ||
); | ||
done(); | ||
}, 400); | ||
}, 600); | ||
}); | ||
}); |
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
Oops, something went wrong.