Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Apr 14, 2021
1 parent 2b6ddfd commit 88d4c15
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { shallow } from 'enzyme';
import { DocViewerTab } from './doc_viewer_tab';
import { ElasticSearchHit } from '../../doc_views/doc_views_types';

describe('DocViewerTab', () => {
test('changing columns triggers an update', () => {
const props = {
title: 'test',
component: jest.fn(),
id: 1,
render: jest.fn(),
renderProps: {
hit: {} as ElasticSearchHit,
columns: ['test'],
},
};

const wrapper = shallow(<DocViewerTab {...props} />);

const nextProps = {
...props,
renderProps: {
hit: {} as ElasticSearchHit,
columns: ['test2'],
},
};

const shouldUpdate = (wrapper!.instance() as DocViewerTab).shouldComponentUpdate(nextProps, {
hasError: false,
error: '',
});
expect(shouldUpdate).toBe(true);
});
});

0 comments on commit 88d4c15

Please sign in to comment.