mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 10:00:17 -04:00
* 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
82 lines
1.9 KiB
JavaScript
82 lines
1.9 KiB
JavaScript
import React from "react";
|
|
import enzyme from "enzyme";
|
|
|
|
import getOptions from "../getOptions";
|
|
import SeriesSettings from "./SeriesSettings";
|
|
|
|
function findByTestID(wrapper, testId) {
|
|
return wrapper.find(`[data-test="${testId}"]`);
|
|
}
|
|
|
|
function mount(options, done) {
|
|
options = getOptions(options);
|
|
return enzyme.mount(
|
|
<SeriesSettings
|
|
visualizationName="Test"
|
|
data={{ columns: [{ name: "a", type: "string" }], rows: [{ a: "test" }] }}
|
|
options={options}
|
|
onOptionsChange={changedOptions => {
|
|
expect(changedOptions).toMatchSnapshot();
|
|
done();
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
describe("Visualizations -> Chart -> Editor -> Series Settings", () => {
|
|
test("Changes series type", done => {
|
|
const el = mount(
|
|
{
|
|
globalSeriesType: "column",
|
|
columnMapping: { a: "y" },
|
|
seriesOptions: {
|
|
a: { type: "column", label: "a", yAxis: 0 },
|
|
},
|
|
},
|
|
done
|
|
);
|
|
|
|
findByTestID(el, "Chart.Series.a.Type")
|
|
.last()
|
|
.simulate("click");
|
|
findByTestID(el, "Chart.ChartType.area")
|
|
.last()
|
|
.simulate("click");
|
|
});
|
|
|
|
test("Changes series label", done => {
|
|
const el = mount(
|
|
{
|
|
globalSeriesType: "column",
|
|
columnMapping: { a: "y" },
|
|
seriesOptions: {
|
|
a: { type: "column", label: "a", yAxis: 0 },
|
|
},
|
|
},
|
|
done
|
|
);
|
|
|
|
findByTestID(el, "Chart.Series.a.Label")
|
|
.last()
|
|
.simulate("change", { target: { value: "test" } });
|
|
});
|
|
|
|
test("Changes series axis", done => {
|
|
const el = mount(
|
|
{
|
|
globalSeriesType: "column",
|
|
columnMapping: { a: "y" },
|
|
seriesOptions: {
|
|
a: { type: "column", name: "a", yAxis: 0 },
|
|
},
|
|
},
|
|
done
|
|
);
|
|
|
|
findByTestID(el, "Chart.Series.a.UseRightAxis")
|
|
.last()
|
|
.find("input")
|
|
.simulate("change", { target: { checked: true } });
|
|
});
|
|
});
|