Skip to content

Commit

Permalink
fix(get-updates): add test for retrieving updates when initial API ve…
Browse files Browse the repository at this point in the history
…rsion is undefined and secondary request fails
  • Loading branch information
guidomodarelli committed Dec 17, 2024
1 parent de89706 commit d830303
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,42 @@ describe('getUpdates function', () => {
],
});
});
it('should return available updates from api when in the first request, api_version is undefined and the second request fail', async () => {
const semver = {
major: 4,
minor: 3,
patch: 1,
};
const version = `${semver.major}.${semver.minor}.${semver.patch}`;
mockRequest
.mockImplementationOnce(() => ({
data: {
data: {
api_version: undefined,
},
},
}))
.mockImplementationOnce(() => {
throw new Error('Error');
});

const updates = await getUpdates(true);

expect(updates).toEqual({
last_check_date: expect.any(Date),
apis_available_updates: [
{
api_id: API_ID,
current_version: undefined,
status: API_UPDATES_STATUS.ERROR,
error: {
detail: 'Error',
title: 'Error',
},
},
],
});
});
it('should return available updates from api when the first request fail', async () => {
const semver = {
major: 4,
Expand Down

0 comments on commit d830303

Please sign in to comment.