mirror of
https://github.com/supabase/supabase.git
synced 2026-05-08 01:40:13 -04:00
4a0bb36ca8
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { getMappingForError } from './ErrorMatcher.utils'
|
|
import { ConnectionTimeoutError, UnknownAPIResponseError } from '@/types/api-errors'
|
|
|
|
describe('getMappingForError', () => {
|
|
it('returns the mapping for a classified error with a known errorType', () => {
|
|
const error = new ConnectionTimeoutError('connection terminated due to connection timeout')
|
|
const mapping = getMappingForError(error)
|
|
expect(mapping).not.toBeNull()
|
|
expect(mapping?.id).toBe('connection-timeout')
|
|
})
|
|
|
|
it('returns null for UnknownAPIResponseError (no troubleshooting guide)', () => {
|
|
const error = new UnknownAPIResponseError('something went wrong')
|
|
expect(getMappingForError(error)).toBeNull()
|
|
})
|
|
|
|
it('returns null for a plain string', () => {
|
|
expect(getMappingForError('some error message')).toBeNull()
|
|
})
|
|
|
|
it('returns null for null', () => {
|
|
expect(getMappingForError(null)).toBeNull()
|
|
})
|
|
|
|
it('returns null for an object with no errorType', () => {
|
|
expect(getMappingForError({ message: 'error' })).toBeNull()
|
|
})
|
|
|
|
it('returns null for an object with an unrecognised errorType', () => {
|
|
expect(getMappingForError({ errorType: 'not-a-real-type' })).toBeNull()
|
|
})
|
|
})
|