Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Dec 12, 2019
1 parent 339a5e9 commit 1fa6e33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { mount, shallow } from 'enzyme';
import { mount } from 'enzyme';
import * as React from 'react';

import { navTabs } from '../../../pages/home/home_navigations';
Expand Down Expand Up @@ -60,13 +60,13 @@ describe('Tab Navigation', () => {
},
};
test('it mounts with correct tab highlighted', () => {
const wrapper = shallow(<TabNavigationComponent {...mockProps} />);
const hostsTab = wrapper.find('[data-test-subj="navigation-hosts"]');
const wrapper = mount(<TabNavigationComponent {...mockProps} />);
const hostsTab = wrapper.find('EuiTab[data-test-subj="navigation-hosts"]');
expect(hostsTab.prop('isSelected')).toBeTruthy();
});
test('it changes active tab when nav changes by props', () => {
const wrapper = mount(<TabNavigationComponent {...mockProps} />);
const networkTab = () => wrapper.find('[data-test-subj="navigation-network"]').first();
const networkTab = () => wrapper.find('EuiTab[data-test-subj="navigation-network"]').first();
expect(networkTab().prop('isSelected')).toBeFalsy();
wrapper.setProps({
pageName: 'network',
Expand All @@ -77,8 +77,8 @@ describe('Tab Navigation', () => {
expect(networkTab().prop('isSelected')).toBeTruthy();
});
test('it carries the url state in the link', () => {
const wrapper = shallow(<TabNavigationComponent {...mockProps} />);
const firstTab = wrapper.find('[data-test-subj="navigation-network"]');
const wrapper = mount(<TabNavigationComponent {...mockProps} />);
const firstTab = wrapper.find('EuiTab[data-test-subj="navigation-network"]');
expect(firstTab.props().href).toBe(
"#/link-to/network?query=(language:kuery,query:'host.name:%22siem-es%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:1558048243696,fromStr:now-24h,kind:relative,to:1558134643697,toStr:now)),timeline:(linkTo:!(global),timerange:(from:1558048243696,fromStr:now-24h,kind:relative,to:1558134643697,toStr:now)))"
);
Expand Down Expand Up @@ -124,9 +124,9 @@ describe('Tab Navigation', () => {
},
};
test('it mounts with correct tab highlighted', () => {
const wrapper = shallow(<TabNavigationComponent {...mockProps} />);
const wrapper = mount(<TabNavigationComponent {...mockProps} />);
const tableNavigationTab = wrapper.find(
`[data-test-subj="navigation-${HostsTableType.authentications}"]`
`EuiTab[data-test-subj="navigation-${HostsTableType.authentications}"]`
);

expect(tableNavigationTab.prop('isSelected')).toBeTruthy();
Expand All @@ -145,9 +145,9 @@ describe('Tab Navigation', () => {
expect(tableNavigationTab().prop('isSelected')).toBeTruthy();
});
test('it carries the url state in the link', () => {
const wrapper = shallow(<TabNavigationComponent {...mockProps} />);
const wrapper = mount(<TabNavigationComponent {...mockProps} />);
const firstTab = wrapper.find(
`[data-test-subj="navigation-${HostsTableType.authentications}"]`
`EuiTab[data-test-subj="navigation-${HostsTableType.authentications}"]`
);
expect(firstTab.props().href).toBe(
`#/${pageName}/${hostName}/${HostsTableType.authentications}?query=(language:kuery,query:'host.name:%22siem-es%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:1558048243696,fromStr:now-24h,kind:relative,to:1558134643697,toStr:now)),timeline:(linkTo:!(global),timerange:(from:1558048243696,fromStr:now-24h,kind:relative,to:1558134643697,toStr:now)))`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const TabNavigationComponent = (props: TabNavigationProps) => {
/>
);
}),
[navTabs]
[navTabs, selectedTabId]
);

return <EuiTabs display={display}>{renderTabs}</EuiTabs>;
Expand Down

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

0 comments on commit 1fa6e33

Please sign in to comment.