Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mgunnerud committed Dec 18, 2024
1 parent 335fe2a commit 3b84378
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const defaultAccessPackageProp = {
id: 'urn:altinn:accesspackage:sjofart',
urn: 'urn:altinn:accesspackage:sjofart',
name: 'Sjøfart',
description:
'Denne fullmakten gir tilgang til alle tjenester knyttet til skipsarbeidstakere og fartøy til sjøs. Ved regelverksendringer eller innføring av nye digitale tjenester kan det bli endringer i tilganger som fullmakten gir.',
description: '',
};

const resource = {
Expand Down Expand Up @@ -43,7 +42,9 @@ describe('PolicyAccessPackageAccordion', () => {
const user = userEvent.setup();
renderPolicyAccessPackageAccordion();

const accordionButton = screen.getByRole('button');
const accordionButton = screen.getByRole('button', {
name: defaultAccessPackageProp.name,
});
await user.click(accordionButton);

expect(
Expand All @@ -59,7 +60,9 @@ describe('PolicyAccessPackageAccordion', () => {

renderPolicyAccessPackageAccordion({ getAccessPackageServices });

const accordionButton = screen.getByRole('button');
const accordionButton = screen.getByRole('button', {
name: defaultAccessPackageProp.name,
});
await user.click(accordionButton);

expect(screen.getByText(resource.title.nb)).toBeInTheDocument();
Expand All @@ -75,7 +78,9 @@ describe('PolicyAccessPackageAccordion', () => {

renderPolicyAccessPackageAccordion({ getAccessPackageServices });

const accordionButton = screen.getByRole('button');
const accordionButton = screen.getByRole('button', {
name: defaultAccessPackageProp.name,
});
await user.click(accordionButton);

expect(screen.getByAltText(resource.hasCompetentAuthority.name.nb)).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ describe('PolicyAccordion', () => {
it('should show children when expanded', async () => {
const user = userEvent.setup();
const childElementText = 'TEST CHILD ELEMENT';
const buttonText = 'Test';
render(
<PolicyAccordion icon='TruckIcon' title='Test' subTitle='SubTest'>
<PolicyAccordion icon='TruckIcon' title={buttonText} subTitle=''>
<div>{childElementText}</div>
</PolicyAccordion>,
);

const accordionButton = screen.getByRole('button');
const accordionButton = screen.getByRole('button', { name: buttonText });
await user.click(accordionButton);

expect(screen.getByText(childElementText)).toBeInTheDocument();
Expand Down

0 comments on commit 3b84378

Please sign in to comment.