MapToPoster / frontend /src /api.test.ts
isaachwf's picture
Sync from GitHub via hub-sync
7604e0d verified
Raw History Blame Contribute Delete
570 Bytes
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { PosterRequest } from './types'
import { prepareMap } from './api'
describe('API network errors', () => {
afterEach(() => vi.unstubAllGlobals())
it('replaces the browser Failed to fetch message with actionable guidance', async () => {
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new TypeError('Failed to fetch')))
await expect(prepareMap({} as PosterRequest)).rejects.toThrow(
'The map request was interrupted. Please retry or zoom in to a smaller area.',
)
})
})