forked from TanStack/db
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.test.ts
More file actions
25 lines (21 loc) · 814 Bytes
/
errors.test.ts
File metadata and controls
25 lines (21 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { describe, expect, it } from "vitest"
import { NonRetriableError } from "../src/errors"
describe(`Errors`, () => {
it(`should create a NonRetriableError with the correct name and message`, () => {
const errorMessage = `This is a non-retriable error`
const error = new NonRetriableError(errorMessage)
expect(error).toBeInstanceOf(Error)
expect(error.name).toBe(`NonRetriableError`)
expect(error.message).toBe(errorMessage)
})
it(`should be catchable as an Error`, () => {
const errorMessage = `This is a non-retriable error`
try {
throw new NonRetriableError(errorMessage)
} catch (error) {
expect(error).toBeInstanceOf(Error)
expect(error).toBeInstanceOf(NonRetriableError)
expect((error as Error).message).toBe(errorMessage)
}
})
})