File size: 721 Bytes
23ac194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
'use strict'

const { test } = require('node:test')
const build = require('..')

test('Should clean the cache', (t) => {
  t.plan(1)

  const schema = {
    $id: 'test',
    type: 'string'
  }

  t.assert.doesNotThrow(() => {
    build(schema)
    build(schema)
  })
})

test('Should clean the cache with external schemas', (t) => {
  t.plan(1)

  const schema = {
    $id: 'test',
    definitions: {
      def: {
        type: 'object',
        properties: {
          str: {
            type: 'string'
          }
        }
      }
    },
    type: 'object',
    properties: {
      obj: {
        $ref: '#/definitions/def'
      }
    }
  }

  t.assert.doesNotThrow(() => {
    build(schema)
    build(schema)
  })
})