Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Sep 18, 2020
1 parent cfc4d21 commit bb478aa
Show file tree
Hide file tree
Showing 3 changed files with 255 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { shallow } from 'enzyme';

// @ts-expect-error
import { ResolutionEditor } from './resolution_editor';
import { GRID_RESOLUTION } from '../../../../common/constants';

const defaultProps = {
resolution: GRID_RESOLUTION.COARSE,
onChange: () => {},
includeSuperFine: false,
};

describe('resolution editor', () => {
test('should omit super-fine option', async () => {
const component = shallow(<ResolutionEditor />);
expect(component).toMatchSnapshot();
});
test('should add super-fine option', async () => {
const component = shallow(<ResolutionEditor includeSuperFine={true} />);
expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { shallow } from 'enzyme';

// @ts-expect-error
import { UpdateSourceEditor } from './update_source_editor';
import { GRID_RESOLUTION, LAYER_TYPE, RENDER_AS } from '../../../../common/constants';

const defaultProps = {
currentLayerType: LAYER_TYPE.VECTOR,
indexPatternId: 'foobar',
onChange: () => {},
metrics: [],
renderAs: RENDER_AS.POINT,
resolution: GRID_RESOLUTION.COARSE,
};

describe('source editor geo_grid_source', () => {
describe('default vector layer config', () => {
test('should allow super-fine option', async () => {
const component = shallow(<UpdateSourceEditor {...defaultProps} />);
expect(component).toMatchSnapshot();
});
});

describe('should put limitations based on heatmap-rendering selection', () => {
test('should not allow super-fine option for heatmaps', async () => {
const component = shallow(
<UpdateSourceEditor {...defaultProps} currentLayerType={LAYER_TYPE.HEATMAP} />
);
expect(component).toMatchSnapshot();
});
test('should disable multiple metrics', async () => {
const component = shallow(
<UpdateSourceEditor {...defaultProps} renderAs={RENDER_AS.HEATMAP} />
);
expect(component).toMatchSnapshot();
});
});
});

0 comments on commit bb478aa

Please sign in to comment.