Skip to content

Commit

Permalink
Improves the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Feb 12, 2022
1 parent 59f6f12 commit 18e417a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,34 +594,21 @@ describe('utils', () => {
expect(exceptions).toEqual([getExceptionListItemSchemaMock()]);
});

test('it throws if "getExceptionListClient" fails', async () => {
test('it throws if "findExceptionListsItemPointInTimeFinder" fails anywhere', async () => {
const err = new Error('error fetching list');
listMock.getExceptionListClient = () =>
({
getExceptionList: jest.fn().mockRejectedValue(err),
findExceptionListsItemPointInTimeFinder: jest.fn().mockRejectedValue(err),
} as unknown as ExceptionListClient);

await expect(() =>
getExceptions({
client: listMock.getExceptionListClient(),
lists: getListArrayMock(),
})
).rejects.toThrowError('unable to fetch exception list items');
});

test('it throws if "findExceptionListsItem" fails', async () => {
const err = new Error('error fetching list');
listMock.getExceptionListClient = () =>
({
findExceptionListsItem: jest.fn().mockRejectedValue(err),
} as unknown as ExceptionListClient);

await expect(() =>
getExceptions({
client: listMock.getExceptionListClient(),
lists: getListArrayMock(),
})
).rejects.toThrowError('unable to fetch exception list items');
).rejects.toThrowError(
'unable to fetch exception list items, message: "error fetching list" full error: "Error: error fetching list"'
);
});

test('it returns empty array if "findExceptionListsItem" returns null', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const getExceptions = async ({
return items;
} catch (e) {
throw new Error(
`unable to fetch exception list items, message: ${e.message} full error: ${e}`
`unable to fetch exception list items, message: "${e.message}" full error: "${e}"`
);
}
} else {
Expand Down

0 comments on commit 18e417a

Please sign in to comment.