Skip to content

Commit

Permalink
916 Combines 2 similar tests into one parameterized test
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardovdheijden committed May 16, 2024
1 parent 361b9bf commit 17814d2
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@ describe('menuItemIsAllowed', () => {
isAllowedHandlerMock.mockClear();
});

it('returns true when url is undefined', () => {
const url = undefined;

const result = menuItemIsAllowed(url, testUrlMap, isAllowedHandlerMock);

expect(result).toEqual(true);
expect(isAllowedHandlerMock).not.toHaveBeenCalled();
});

it('returns true when url is an empty string', () => {
const url = '';

const result = menuItemIsAllowed(url, testUrlMap, isAllowedHandlerMock);

expect(result).toEqual(true);
expect(isAllowedHandlerMock).not.toHaveBeenCalled();
});
it.each([undefined, ''])(
'returns true when the value of the url is: "%s"',
(url) => {
const result = menuItemIsAllowed(
url,
testUrlMap,
isAllowedHandlerMock,
);

expect(result).toEqual(true);
expect(isAllowedHandlerMock).not.toHaveBeenCalled();
},
);

it('returns the result of the isAllowedHandler when url is in the url-map', () => {
const url = '/testUrl1';
Expand Down

0 comments on commit 17814d2

Please sign in to comment.