From ae9e5a0566ef70abc0b91f72aa3f571600ab835e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 14 Feb 2022 20:04:38 +0100 Subject: [PATCH] Fixed tests --- test/app/App.test.tsx | 2 +- test/common/MainHeader.test.tsx | 2 ++ test/settings/Settings.test.tsx | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/app/App.test.tsx b/test/app/App.test.tsx index 4802a983..1d8ff213 100644 --- a/test/app/App.test.tsx +++ b/test/app/App.test.tsx @@ -54,7 +54,7 @@ describe('', () => { const routes = wrapper.find(Route); const expectedPaths = [ undefined, - '/settings', + '/settings/*', '/manage-servers', '/server/create', '/server/:serverId/edit', diff --git a/test/common/MainHeader.test.tsx b/test/common/MainHeader.test.tsx index b1fa282e..d472a505 100644 --- a/test/common/MainHeader.test.tsx +++ b/test/common/MainHeader.test.tsx @@ -35,6 +35,8 @@ describe('', () => { [ '/foo', false ], [ '/bar', false ], [ '/settings', true ], + [ '/settings/foo', true ], + [ '/settings/bar', true ], ])('sets link to settings as active only when current path is settings', (currentPath, isActive) => { const wrapper = createWrapper(currentPath); const settingsLink = wrapper.find(NavLink); diff --git a/test/settings/Settings.test.tsx b/test/settings/Settings.test.tsx index ffd9ed39..e71083e6 100644 --- a/test/settings/Settings.test.tsx +++ b/test/settings/Settings.test.tsx @@ -1,6 +1,8 @@ import { shallow } from 'enzyme'; +import { Route } from 'react-router-dom'; import createSettings from '../../src/settings/Settings'; import { NoMenuLayout } from '../../src/common/NoMenuLayout'; +import { NavPillItem } from '../../src/utils/NavPills'; describe('', () => { const Component = () => null; @@ -9,10 +11,19 @@ describe('', () => { it('renders a no-menu layout with the expected settings sections', () => { const wrapper = shallow(); const layout = wrapper.find(NoMenuLayout); - const sections = wrapper.find('SettingsSections'); + const sections = wrapper.find(Route); expect(layout).toHaveLength(1); - expect(sections).toHaveLength(1); - expect((sections.prop('items') as any[]).flat()).toHaveLength(6); + expect(sections).toHaveLength(4); + }); + + it('renders expected menu', () => { + const wrapper = shallow(); + const items = wrapper.find(NavPillItem); + + expect(items).toHaveLength(3); + expect(items.first().prop('to')).toEqual('app'); + expect(items.at(1).prop('to')).toEqual('short-urls'); + expect(items.last().prop('to')).toEqual('others'); }); });