@@ -3,25 +3,49 @@ var convert = require('../');
33
44test ( 'cloning schema by default' , function ( assert ) {
55 var schema ;
6+ var cloned ;
67 var result ;
78 var expected ;
89
910 assert . plan ( 2 )
1011
1112 schema = {
1213 type : 'string' ,
13- nullable : true
14+ nullable : true ,
15+ properties : {
16+ foo : true ,
17+ bar : {
18+ allOf : [
19+ null ,
20+ {
21+ type : 'string' ,
22+ } ,
23+ null
24+ ]
25+ }
26+ }
1427 }
1528
16- result = convert ( schema )
29+ cloned = JSON . parse ( JSON . stringify ( schema ) ) ;
30+
31+ result = convert ( cloned )
1732
1833 expected = {
1934 $schema : 'http://json-schema.org/draft-04/schema#' ,
20- type : [ 'string' , 'null' ]
35+ type : [ 'string' , 'null' ] ,
36+ properties : {
37+ bar : {
38+ allOf : [
39+ {
40+ type : 'string' ,
41+ }
42+ ]
43+ }
44+ }
2145 }
2246
2347 assert . deepEqual ( result , expected , 'converted' )
24- assert . notEqual ( result , schema , 'schema cloned' )
48+ assert . deepEqual ( cloned , schema , 'schema cloned' )
2549} )
2650
2751test ( 'cloning schema with cloneSchema option' , function ( assert ) {
@@ -32,6 +56,8 @@ test('cloning schema with cloneSchema option', function (assert) {
3256 nullable : true
3357 }
3458
59+ var cloned = JSON . parse ( JSON . stringify ( schema ) )
60+
3561 var result = convert ( schema , { cloneSchema : true } )
3662
3763 var expected = {
@@ -40,7 +66,7 @@ test('cloning schema with cloneSchema option', function (assert) {
4066 }
4167
4268 assert . deepEqual ( result , expected , 'converted' )
43- assert . notEqual ( result , schema , 'schema cloned' )
69+ assert . deepEqual ( cloned , schema , 'schema cloned' )
4470} )
4571
4672test ( 'handles circular references' , function ( assert ) {
0 commit comments