Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw committed Aug 13, 2019
1 parent 6221dd6 commit a587d63
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions packages/superset-ui-chart/test/models/ChartProps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const RAW_DATASOURCE = {
another_field: 2,
};

const PAYLOAD = {};
const QUERY_DATA = {};

describe('ChartProps', () => {
it('exists', () => {
Expand All @@ -20,31 +20,17 @@ describe('ChartProps', () => {
width: 800,
height: 600,
formData: RAW_FORM_DATA,
payload: PAYLOAD,
queryData: QUERY_DATA,
});
expect(props).toBeInstanceOf(ChartProps);
});
it('sets all handlers to NOOP by default', () => {
const props = new ChartProps({
width: 800,
height: 600,
formData: RAW_FORM_DATA,
payload: PAYLOAD,
});
expect(() => {
props.onAddFilter();
props.onError();
props.setControlValue();
props.setTooltip();
}).not.toThrow();
});
it('processes formData and datasource to convert field names to camelCase', () => {
const props = new ChartProps({
width: 800,
height: 600,
datasource: RAW_DATASOURCE,
formData: RAW_FORM_DATA,
payload: PAYLOAD,
queryData: QUERY_DATA,
});
expect(props.formData.someField).toEqual(1);
expect(props.datasource.anotherField).toEqual(2);
Expand All @@ -63,14 +49,14 @@ describe('ChartProps', () => {
height: 600,
datasource: RAW_DATASOURCE,
formData: RAW_FORM_DATA,
payload: PAYLOAD,
queryData: QUERY_DATA,
});
const props2 = selector({
width: 800,
height: 600,
datasource: RAW_DATASOURCE,
formData: RAW_FORM_DATA,
payload: PAYLOAD,
queryData: QUERY_DATA,
});
expect(props1).toBe(props2);
});
Expand All @@ -80,21 +66,21 @@ describe('ChartProps', () => {
height: 600,
datasource: RAW_DATASOURCE,
formData: RAW_FORM_DATA,
payload: PAYLOAD,
queryData: QUERY_DATA,
});
const props2 = selector({
width: 800,
height: 600,
datasource: RAW_DATASOURCE,
formData: { new_field: 3 },
payload: PAYLOAD,
queryData: QUERY_DATA,
});
const props3 = selector({
width: 800,
height: 600,
datasource: RAW_DATASOURCE,
formData: RAW_FORM_DATA,
payload: PAYLOAD,
queryData: QUERY_DATA,
});
expect(props1).not.toBe(props2);
expect(props1).not.toBe(props3);
Expand Down

0 comments on commit a587d63

Please sign in to comment.