import React from 'react'; import { MemoryRouter } from 'react-router-dom'; import { mount } from 'enzyme'; import { Nav } from '@patternfly/react-core'; import NavExpandableGroup from '../../src/components/NavExpandableGroup'; describe('NavExpandableGroup', () => { test('initialization and render', () => { const component = mount( ).find('NavExpandableGroup').instance(); expect(component.navItemPaths).toEqual(['/foo', '/bar', '/fiz']); expect(component.isActiveGroup()).toEqual(true); }); describe('isActivePath', () => { const params = [ ['/fo', '/foo', false], ['/foo', '/foo', true], ['/foo/1/bar/fiz', '/foo', true], ['/foo/1/bar/fiz', 'foo', false], ['/foo/1/bar/fiz', 'foo/', false], ['/foo/1/bar/fiz', '/bar', false], ['/foo/1/bar/fiz', '/fiz', false], ]; params.forEach(([location, path, expected]) => { test(`when location is ${location}', isActivePath('${path}') returns ${expected} `, () => { const component = mount( ).find('NavExpandableGroup').instance(); expect(component.isActivePath(path)).toEqual(expected); }); }); }); });