File size: 570 Bytes
7604e0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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.',
    )
  })
})