test(web): use typed JSON responses in updater checks
This commit is contained in:
@@ -5,7 +5,7 @@ describe('web update checking', () => {
|
|||||||
['same', false],
|
['same', false],
|
||||||
['new-build', true],
|
['new-build', true],
|
||||||
])('compares the deployed build %s', async (version, available) => {
|
])('compares the deployed build %s', async (version, available) => {
|
||||||
const request = vi.fn().mockResolvedValue(new Response(JSON.stringify({ version })));
|
const request = vi.fn().mockResolvedValue(Response.json({ version }));
|
||||||
expect(await checkWebUpdate('same', request)).toEqual({ version, available });
|
expect(await checkWebUpdate('same', request)).toEqual({ version, available });
|
||||||
expect(request).toHaveBeenCalledWith(
|
expect(request).toHaveBeenCalledWith(
|
||||||
'/_app/version.json',
|
'/_app/version.json',
|
||||||
@@ -14,9 +14,7 @@ describe('web update checking', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each([null, {}, { version: '' }, { version: 42 }])('rejects an invalid version response %j', async (body) => {
|
it.each([null, {}, { version: '' }, { version: 42 }])('rejects an invalid version response %j', async (body) => {
|
||||||
await expect(
|
await expect(checkWebUpdate('same', vi.fn().mockResolvedValue(Response.json(body)))).rejects.toThrow();
|
||||||
checkWebUpdate('same', vi.fn().mockResolvedValue(new Response(JSON.stringify(body)))),
|
|
||||||
).rejects.toThrow();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('reports HTTP errors instead of treating them as no updates', async () => {
|
it('reports HTTP errors instead of treating them as no updates', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user