-
Notifications
You must be signed in to change notification settings - Fork 52
/
tests.js
50 lines (40 loc) · 1.21 KB
/
tests.js
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 test from 'ava'
import { validateEdgeFunctionsManifest } from '../../../lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js'
import { removeErrorColors } from '../../../src/error/colors.js'
test('should validate valid manifest', async (t) => {
const manifest = {
bundles: [
{
asset: 'f35baff44129a8f6be7db68590b2efd86ed4ba29000e2edbcaddc5d620d7d043.js',
format: 'js',
},
],
routes: [
{
function: 'hello',
pattern: '^/hello/?$',
},
{
function: 'geolocation',
pattern: '^/geolocation/?$',
},
{
function: 'json',
pattern: '^/json/?$',
},
],
bundler_version: '1.6.0',
}
await t.notThrowsAsync(validateEdgeFunctionsManifest(manifest))
})
test('should print error on invalid manifest', async (t) => {
const manifest = 'json'
const error = await t.throwsAsync(validateEdgeFunctionsManifest(manifest))
removeErrorColors(error)
t.snapshot(error.message)
})
test('should print error on empty manifest', async (t) => {
const error = await t.throwsAsync(validateEdgeFunctionsManifest({}))
removeErrorColors(error)
t.snapshot(error.message)
})