Skip to content

Commit

Permalink
Add test for header theme mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceR committed Nov 21, 2024
1 parent 4b79efc commit 9650683
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion app/scripts/components/common/page-header/page-header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { NavItem, NavItemType } from './types';
import PageHeader from './index';

// @NOTE: Possible Test cases
// light vs dark mode
// config & create dynamic nav menu list fn - different scenerios, happy vs unhappy path

const mockMainNavItems: NavItem[] = [
Expand Down Expand Up @@ -119,3 +118,36 @@ describe('PageHeader', () => {
expect(within(primaryNav).getByText('Submenu 1')).toBeVisible();
});
});

describe('PageHeader light and dark mode', () => {
// @NOTE: We do not test css here, only attributes accessible via DOM
test('the header is in light mode by default', () => {
render(
<PageHeader
mainNavItems={mockMainNavItems}
subNavItems={mockSubNavItems}
logo={<NasaLogoColor />}
linkProperties={mockLinkProperties}
// no mode specified
/>
);
const header = screen.getByTestId('header');

expect(header.id).toEqual('mode-light');
});

test('the header can be changed to dark mode using the prop', () => {
render(
<PageHeader
mainNavItems={mockMainNavItems}
subNavItems={mockSubNavItems}
logo={<NasaLogoColor />}
linkProperties={mockLinkProperties}
mode='dark'
/>
);
const header = screen.getByTestId('header');

expect(header.id).toEqual('mode-dark');
});
});

0 comments on commit 9650683

Please sign in to comment.