-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_pacman.ts
More file actions
41 lines (33 loc) · 1.02 KB
/
test_pacman.ts
File metadata and controls
41 lines (33 loc) · 1.02 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
import assert from 'node:assert/strict'
import { after, beforeEach, describe, it } from 'node:test'
import { BaseApiClient } from './base.ts'
import { PACMAN_REPOSITORY_SCHEMA } from '../../common/services.ts'
import { assertTrue } from '../assertion.ts'
describe('/api/pacman', function () {
let client: BaseApiClient
beforeEach(async function () {
if (client) {
await client.reset()
} else {
client = await BaseApiClient.initialize()
}
})
after(async function () {
await client?.finalize()
})
it('matches the repository schema at the root', async function () {
const response = await client.get('/api/pacman')
const payload = await response.json()
assertTrue(
PACMAN_REPOSITORY_SCHEMA.matches(payload),
)
})
it('errors out with 404 on subpaths', async function () {
const response = await client.get('/api/pacman/invalid')
assert.equal(response.status(), 404)
assert.deepEqual(
await response.json(),
{ errorKind: 'http', code: 404 },
)
})
})