test(web): use typed JSON responses in updater checks
This commit is contained in:
@@ -5,7 +5,7 @@ describe('web update checking', () => {
|
||||
['same', false],
|
||||
['new-build', true],
|
||||
])('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(request).toHaveBeenCalledWith(
|
||||
'/_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) => {
|
||||
await expect(
|
||||
checkWebUpdate('same', vi.fn().mockResolvedValue(new Response(JSON.stringify(body)))),
|
||||
).rejects.toThrow();
|
||||
await expect(checkWebUpdate('same', vi.fn().mockResolvedValue(Response.json(body)))).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('reports HTTP errors instead of treating them as no updates', async () => {
|
||||
|
||||
Reference in New Issue
Block a user