-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy patherrors.test.ts
More file actions
50 lines (43 loc) · 1.19 KB
/
errors.test.ts
File metadata and controls
50 lines (43 loc) · 1.19 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { LoguxUndoError } from '@logux/client'
import { equal } from 'node:assert/strict'
import { afterEach, describe, test } from 'node:test'
import { notFound, NotFoundError } from '../errors.ts'
import { cleanClientTest, enableClientTest, setBaseTestRoute } from './utils.ts'
describe('errors', () => {
afterEach(async () => {
await cleanClientTest()
})
test('listens for not found error', () => {
let listener: (e: { reason: Error }) => undefined | void
enableClientTest({
errorEvents: {
addEventListener(event, cb) {
listener = cb
}
}
})
setBaseTestRoute({
params: { feed: 'unknown' },
route: 'feedsByCategories'
})
equal(notFound.get(), false)
listener!({
reason: new LoguxUndoError({
action: { channel: 'feeds/unknown', type: 'logux/subscribe' },
id: '1 1:0:0 0',
reason: 'notFound',
type: 'logux/undo'
})
})
equal(notFound.get(), true)
setBaseTestRoute({
params: { feed: 'another' },
route: 'feedsByCategories'
})
equal(notFound.get(), false)
listener!({
reason: new NotFoundError()
})
equal(notFound.get(), true)
})
})