Files
redash/client/app/visualizations/table/columns/image.test.js
Levko Kravets 7157244eec Migrate Table visualization to React Part 2: Editor (#4175)
* Migrate table editor to React: skeleton, Grid tab

* Columns tab

* Cleanup

* Columns tab: DnD column sorting

* Columns types should be JSX

* New Columns tab UI/X

* Use Sortable component on Columns tab

* Tests: Grid Settings

* Tests: Columns Settings

* Tests: Editors for Text, Number, Boolean and Date/Time columns

* Tests: Editors for Image and Link columns

* Minor UI fix

* Trigger build

* Debounce inputs
2019-10-24 12:46:46 +03:00

66 lines
1.7 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').first().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').first().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').first().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').first().find('input')
.simulate('change', { target: { value: 'Image {{ @ }}' } });
});
});
});