1
+ "use strict" ;
2
+
3
+ const { expect} = require ( "chai" ) ;
4
+ const { LazyJson} = require ( "../../dist" ) ;
5
+ const { FileCache} = require ( "../../dist/resolver/external" ) ;
6
+
7
+ describe ( "Pets" , ( ) => {
8
+ describe ( "parse" , ( ) => {
9
+ it ( "should parse a simple reference" , async ( ) => {
10
+ FileCache . GLOBAL . reset ( ) ;
11
+
12
+ let json = LazyJson . create ( __dirname + "/definitions/pets.json" ) ;
13
+
14
+ expect ( json . properties . cat ) . to . deep . equal ( json . definitions . pet ) ;
15
+ expect ( json . properties . dog ) . to . deep . equal ( json . definitions . pet ) ;
16
+ expect ( json . properties . cat ) . to . deep . equal ( json . properties . dog )
17
+ } ) ;
18
+
19
+ } ) ;
20
+
21
+ describe ( "change" , ( ) => {
22
+ it ( "should change all references" , async ( ) => {
23
+ FileCache . GLOBAL . reset ( ) ;
24
+
25
+ let json = LazyJson . create ( __dirname + "/definitions/pets.json" ) ;
26
+
27
+ json . definitions . pet . type = "Animal" ;
28
+
29
+ expect ( json . properties . cat . type ) . to . equal ( "Animal" ) ;
30
+ expect ( json . properties . dog . type ) . to . equal ( "Animal" ) ;
31
+ } ) ;
32
+
33
+ it ( "reference change should change source" , async ( ) => {
34
+ FileCache . GLOBAL . reset ( ) ;
35
+
36
+ let json = LazyJson . create ( __dirname + "/definitions/pets.json" ) ;
37
+
38
+ json . properties . cat . required = [ "category" ] ;
39
+
40
+ expect ( json . definitions . pet . required ) . to . deep . equal ( [ "category" ] ) ;
41
+ expect ( json . properties . dog . required ) . to . deep . equal ( [ "category" ] ) ;
42
+ } ) ;
43
+ } ) ;
44
+ } ) ;
0 commit comments