Debian Codegraph @

fast-uri/test/ajv.test.js

raw
1 'use strict'
2
3 const test = require('tape')
4 const fastURI = require('..')
5
6 const AJV = require('ajv')
7
8 const ajv = new AJV({
9 uriResolver: fastURI // comment this line to see it works with uri-js
10 })
11
12 test('ajv', t => {
13 t.plan(1)
14 const schema = {
15 $ref: '#/definitions/Record%3Cstring%2CPerson%3E',
16 definitions: {
17 Person: {
18 type: 'object',
19 properties: {
20 firstName: {
21 type: 'string'
22 }
23 }
24 },
25 'Record<string,Person>': {
26 type: 'object',
27 additionalProperties: {
28 $ref: '#/definitions/Person'
29 }
30 }
31 }
32 }
33
34 const data = {
35 joe: {
36 firstName: 'Joe'
37 }
38
39 }
40
41 const validate = ajv.compile(schema)
42 t.ok(validate(data))
43 })