Skip to content

Commit

Permalink
Merge pull request #78 from sebgroup/develop
Browse files Browse the repository at this point in the history
next release
  • Loading branch information
eweseong committed Jun 6, 2023
2 parents 7565801 + c945283 commit 3e5115a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
Expand Up @@ -37,7 +37,7 @@
}

a {
padding-inline: 1rem;
padding-left: 1rem;
}
}

Expand Down
Expand Up @@ -101,7 +101,7 @@ describe('Component: WizardNavigations', () => {
expect(screen.getByRole('listitem')).toHaveClass('introduction');
});

it('Should render sub navigations correctly', () => {
describe('sub navigations', () => {
const navigations = [
{
label: 'Step 1',
Expand Down Expand Up @@ -131,19 +131,46 @@ describe('Component: WizardNavigations', () => {
step: 4,
},
];
renderWithRouter({ navigations });
navigations.forEach((navigation: WizardNavigationData) => {
assertLinkExist(navigation.label);
navigation.subNavigations?.forEach((subNavigation) => {
assertLinkExist(subNavigation.label);

function assertSubNavigationsVisibility(visible: boolean) {
const [, subNavigations] = screen.getAllByRole('list');

if (visible) {
expect(subNavigations).not.toHaveClass('d-none');
} else {
expect(subNavigations).toHaveClass('d-none');
}
}

it('Should render sub navigations correctly', () => {
renderWithRouter({ navigations });
navigations.forEach((navigation: WizardNavigationData) => {
assertLinkExist(navigation.label);
navigation.subNavigations?.forEach((subNavigation) => {
assertLinkExist(subNavigation.label);
});
});
expect(screen.getAllByRole('link')).toHaveLength(
navigations.flatMap((navigation) => [
navigation,
...(navigation.subNavigations ?? []),
]).length
);
});

it('Should hide sub navigations when not needed', async () => {
renderWithRouter({ navigations });
assertSubNavigationsVisibility(false);
});

it('Should show sub navigations when needed', async () => {
mockedUseNavigationContext.mockImplementation(() => ({
...defaultNavigationInterface,
activeStep: 1,
}));
renderWithRouter({ navigations });
assertSubNavigationsVisibility(true);
});
expect(screen.getAllByRole('link')).toHaveLength(
navigations.flatMap((navigation) => [
navigation,
...(navigation.subNavigations ?? []),
]).length
);
});

it('Should inject tokens into navigation description when placeholders exists', () => {
Expand Down
Expand Up @@ -127,7 +127,9 @@ const WizardNavigationList = React.forwardRef(
/>
{Array.isArray(subNavigations) && (
<WizardNavigationList
className="list-group list-group-ordered"
className={classnames('list-group list-group-ordered', {
'd-none': !(isActive || isCompleted),
})}
navigations={subNavigations}
setToggle={setToggle}
/>
Expand Down
1 change: 0 additions & 1 deletion src/setupTests.ts
Expand Up @@ -22,5 +22,4 @@ global.defaultNavigationInterface = {
setActiveState: jest.fn(),
setActiveStep: jest.fn(),
setRoutes: jest.fn(),
setStrict: jest.fn(),
};

0 comments on commit 3e5115a

Please sign in to comment.