Files
redash/client/app/visualizations/chart/Editor/XAxisSettings.test.js
Arik Fraimovich 56d3be2248 Prettier all the Javascript code & GitHub Action (#4433)
* Prettier all the JS files

* Add GitHub Action to autoformat code pushed to master

* Fix eslint violation due to formatting.

* Remove GitHub actions for styling

* Add restyled.io config
2019-12-11 17:05:38 +02:00

100 lines
2.1 KiB
JavaScript

import React from "react";
import enzyme from "enzyme";
import getOptions from "../getOptions";
import XAxisSettings from "./XAxisSettings";
function findByTestID(wrapper, testId) {
return wrapper.find(`[data-test="${testId}"]`);
}
function mount(options, done) {
options = getOptions(options);
return enzyme.mount(
<XAxisSettings
visualizationName="Test"
data={{ columns: [], rows: [] }}
options={options}
onOptionsChange={changedOptions => {
expect(changedOptions).toMatchSnapshot();
done();
}}
/>
);
}
describe("Visualizations -> Chart -> Editor -> X-Axis Settings", () => {
test("Changes axis type", done => {
const el = mount(
{
globalSeriesType: "column",
xAxis: { type: "-", labels: { enabled: true } },
},
done
);
findByTestID(el, "Chart.XAxis.Type")
.last()
.simulate("click");
findByTestID(el, "Chart.XAxis.Type.Linear")
.last()
.simulate("click");
});
test("Changes axis name", done => {
const el = mount(
{
globalSeriesType: "column",
xAxis: { type: "-", labels: { enabled: true } },
},
done
);
findByTestID(el, "Chart.XAxis.Name")
.last()
.simulate("change", { target: { value: "test" } });
});
test("Sets Show Labels option", done => {
const el = mount(
{
globalSeriesType: "column",
xAxis: { type: "-", labels: { enabled: false } },
},
done
);
findByTestID(el, "Chart.XAxis.ShowLabels")
.last()
.simulate("click");
});
test("Sets Sort X Values option", done => {
const el = mount(
{
globalSeriesType: "column",
sortX: false,
},
done
);
findByTestID(el, "Chart.XAxis.Sort")
.last()
.simulate("click");
});
test("Sets Reverse X Values option", done => {
const el = mount(
{
globalSeriesType: "column",
reverseX: false,
},
done
);
findByTestID(el, "Chart.XAxis.Reverse")
.last()
.simulate("click");
});
});