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
86 lines
1.8 KiB
JavaScript
86 lines
1.8 KiB
JavaScript
import React from "react";
|
|
import enzyme from "enzyme";
|
|
|
|
import Column from "./image";
|
|
|
|
function findByTestID(wrapper, testId) {
|
|
return wrapper.find(`[data-test="${testId}"]`);
|
|
}
|
|
|
|
function mount(column, done) {
|
|
return enzyme.mount(
|
|
<Column.Editor
|
|
visualizationName="Test"
|
|
column={column}
|
|
onChange={changedColumn => {
|
|
expect(changedColumn).toMatchSnapshot();
|
|
done();
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
describe("Visualizations -> Table -> Columns -> Image", () => {
|
|
describe("Editor", () => {
|
|
test("Changes URL template", done => {
|
|
const el = mount(
|
|
{
|
|
name: "a",
|
|
imageUrlTemplate: "{{ @ }}",
|
|
},
|
|
done
|
|
);
|
|
|
|
findByTestID(el, "Table.ColumnEditor.Image.UrlTemplate")
|
|
.last()
|
|
.find("input")
|
|
.simulate("change", { target: { value: "http://{{ @ }}.jpeg" } });
|
|
});
|
|
|
|
test("Changes width", done => {
|
|
const el = mount(
|
|
{
|
|
name: "a",
|
|
imageWidth: null,
|
|
},
|
|
done
|
|
);
|
|
|
|
findByTestID(el, "Table.ColumnEditor.Image.Width")
|
|
.last()
|
|
.find("input")
|
|
.simulate("change", { target: { value: "400" } });
|
|
});
|
|
|
|
test("Changes height", done => {
|
|
const el = mount(
|
|
{
|
|
name: "a",
|
|
imageHeight: null,
|
|
},
|
|
done
|
|
);
|
|
|
|
findByTestID(el, "Table.ColumnEditor.Image.Height")
|
|
.last()
|
|
.find("input")
|
|
.simulate("change", { target: { value: "300" } });
|
|
});
|
|
|
|
test("Changes title template", done => {
|
|
const el = mount(
|
|
{
|
|
name: "a",
|
|
imageUrlTemplate: "{{ @ }}",
|
|
},
|
|
done
|
|
);
|
|
|
|
findByTestID(el, "Table.ColumnEditor.Image.TitleTemplate")
|
|
.last()
|
|
.find("input")
|
|
.simulate("change", { target: { value: "Image {{ @ }}" } });
|
|
});
|
|
});
|
|
});
|