File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9898 }
9999 }
100100 return value ;
101- }
101+ } ;
102+
103+ /**
104+ * Creates a deep clone of the given value.
105+ */
106+ helper . cloneDeep = function cloneDeep ( value ) {
107+ var clone = value ;
108+ if ( value && typeof ( value ) === 'object' ) {
109+ clone = value instanceof Array ? [ ] : { } ;
110+ var keys = Object . keys ( value ) ;
111+ for ( var i = 0 ; i < keys . length ; i ++ ) {
112+ clone [ keys [ i ] ] = helper . cloneDeep ( value [ keys [ i ] ] ) ;
113+ }
114+ }
115+ return clone ;
116+ } ;
102117
103118} ) ( ) ;
Original file line number Diff line number Diff line change 55 var _path = userAgent . isNode ? require ( 'path' ) : null ;
66 var _testsDir = getTestsDir ( ) ;
77
8+ if ( userAgent . isNode ) {
9+ // Run all tests from the "tests" directory
10+ process . chdir ( _path . join ( __dirname , '..' ) ) ;
11+ }
12+
813 /**
914 * Returns the relative path of a file in the "tests" directory
1015 *
1318 path . rel = function ( file ) {
1419 if ( userAgent . isNode ) {
1520 // Return the relative path from the project root
16- return _path . join ( 'tests' , file ) ;
21+ return file ;
1722 }
1823
1924 // Encode special characters in paths when running in a browser
5156 */
5257 function getTestsDir ( ) {
5358 if ( userAgent . isNode ) {
54- return _path . resolve ( 'tests ') ;
59+ return _path . resolve ( __dirname , '.. ') ;
5560 }
5661 else {
5762 var filename = document . querySelector ( 'script[src*="fixtures/helper.js"]' ) . src ;
Original file line number Diff line number Diff line change 5959 < script src ="specs/deep-circular/deep-circular.bundled.js "> </ script >
6060 < script src ="specs/deep-circular/deep-circular.spec.js "> </ script >
6161
62+ < script src ="specs/object-source/object-source.parsed.js "> </ script >
63+ < script src ="specs/object-source/object-source.dereferenced.js "> </ script >
64+ < script src ="specs/object-source/object-source.bundled.js "> </ script >
65+ < script src ="specs/object-source/object-source.spec.js "> </ script >
66+
6267 < script src ="specs/blank/blank.spec.js "> </ script >
6368 < script src ="specs/invalid/invalid.spec.js "> </ script >
6469 < script src ="specs/empty/empty.spec.js "> </ script >
Original file line number Diff line number Diff line change 1+ {
2+ "requiredString" : {
3+ "$ref" : " required-string.yaml"
4+ },
5+ "string" : {
6+ "$ref" : " #/requiredString/type"
7+ },
8+ "name" : {
9+ "$ref" : " ../definitions/name.yaml"
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ title : name
2+ type : object
3+ required :
4+ - first
5+ - last
6+ properties :
7+ first :
8+ $ref : ../definitions/definitions.json#/requiredString
9+ last :
10+ $ref : ./required-string.yaml
11+ middle :
12+ type :
13+ $ref : " #/properties/first/type"
14+ minLength :
15+ $ref : " #/properties/first/minLength"
16+ prefix :
17+ $ref : " #/properties/last"
18+ minLength : 3
19+ suffix :
20+ type : string
21+ $ref : " #/properties/prefix"
22+ maxLength : 3
Original file line number Diff line number Diff line change 1+ title : requiredString
2+ type : string
3+ minLength : 1
Original file line number Diff line number Diff line change 1+ helper . bundled . objectSource =
2+ {
3+ "title" : "Person" ,
4+ "type" : "object" ,
5+ "required" : [
6+ "name"
7+ ] ,
8+ "properties" : {
9+ "name" : {
10+ "$ref" : "#/definitions/name"
11+ } ,
12+ "age" : {
13+ "type" : "integer" ,
14+ "minimum" : 0
15+ } ,
16+ "gender" : {
17+ "type" : "string" ,
18+ "enum" : [
19+ "male" ,
20+ "female"
21+ ]
22+ }
23+ } ,
24+ "definitions" : {
25+ "requiredString" : {
26+ "title" : "requiredString" ,
27+ "type" : "string" ,
28+ "minLength" : 1
29+ } ,
30+ "string" : {
31+ "$ref" : "#/definitions/requiredString/type"
32+ } ,
33+ "name" : {
34+ "title" : "name" ,
35+ "type" : "object" ,
36+ "required" : [
37+ "first" ,
38+ "last"
39+ ] ,
40+ "properties" : {
41+ "first" : {
42+ "$ref" : "#/definitions/requiredString"
43+ } ,
44+ "last" : {
45+ "$ref" : "#/definitions/requiredString"
46+ } ,
47+ "middle" : {
48+ "type" : {
49+ "$ref" : "#/definitions/requiredString/type"
50+ } ,
51+ "minLength" : {
52+ "$ref" : "#/definitions/requiredString/minLength"
53+ }
54+ } ,
55+ "prefix" : {
56+ "$ref" : "#/definitions/requiredString" ,
57+ "minLength" : 3
58+ } ,
59+ "suffix" : {
60+ "$ref" : "#/definitions/name/properties/prefix" ,
61+ "type" : "string" ,
62+ "maxLength" : 3
63+ }
64+ }
65+ }
66+ }
67+ } ;
Original file line number Diff line number Diff line change 1+ helper . dereferenced . objectSource =
2+ {
3+ "title" : "Person" ,
4+ "type" : "object" ,
5+ "required" : [
6+ "name"
7+ ] ,
8+ "properties" : {
9+ "name" : {
10+ "title" : "name" ,
11+ "type" : "object" ,
12+ "required" : [
13+ "first" ,
14+ "last"
15+ ] ,
16+ "properties" : {
17+ "first" : {
18+ "title" : "requiredString" ,
19+ "type" : "string" ,
20+ "minLength" : 1
21+ } ,
22+ "last" : {
23+ "title" : "requiredString" ,
24+ "type" : "string" ,
25+ "minLength" : 1
26+ } ,
27+ "middle" : {
28+ "type" : "string" ,
29+ "minLength" : 1
30+ } ,
31+ "prefix" : {
32+ "title" : "requiredString" ,
33+ "type" : "string" ,
34+ "minLength" : 3
35+ } ,
36+ "suffix" : {
37+ "title" : "requiredString" ,
38+ "type" : "string" ,
39+ "minLength" : 3 ,
40+ "maxLength" : 3
41+ }
42+ }
43+ } ,
44+ "age" : {
45+ "type" : "integer" ,
46+ "minimum" : 0
47+ } ,
48+ "gender" : {
49+ "type" : "string" ,
50+ "enum" : [
51+ "male" ,
52+ "female"
53+ ]
54+ }
55+ } ,
56+ "definitions" : {
57+ "requiredString" : {
58+ "title" : "requiredString" ,
59+ "type" : "string" ,
60+ "minLength" : 1
61+ } ,
62+ "string" : "string" ,
63+ "name" : {
64+ "title" : "name" ,
65+ "type" : "object" ,
66+ "required" : [
67+ "first" ,
68+ "last"
69+ ] ,
70+ "properties" : {
71+ "first" : {
72+ "title" : "requiredString" ,
73+ "type" : "string" ,
74+ "minLength" : 1
75+ } ,
76+ "last" : {
77+ "title" : "requiredString" ,
78+ "type" : "string" ,
79+ "minLength" : 1
80+ } ,
81+ "middle" : {
82+ "type" : "string" ,
83+ "minLength" : 1
84+ } ,
85+ "prefix" : {
86+ "title" : "requiredString" ,
87+ "type" : "string" ,
88+ "minLength" : 3
89+ } ,
90+ "suffix" : {
91+ "title" : "requiredString" ,
92+ "type" : "string" ,
93+ "minLength" : 3 ,
94+ "maxLength" : 3
95+ }
96+ }
97+ }
98+ }
99+ } ;
Original file line number Diff line number Diff line change 1+ var pathToTestsDirectory = global . __karma__ ? '/base/tests/' : '' ;
2+
3+ helper . parsed . objectSource =
4+ {
5+ schema : {
6+ "definitions" : {
7+ "$ref" : pathToTestsDirectory + "specs/object-source/definitions/definitions.json"
8+ } ,
9+ "required" : [
10+ "name"
11+ ] ,
12+ "type" : "object" ,
13+ "properties" : {
14+ "gender" : {
15+ "enum" : [
16+ "male" ,
17+ "female"
18+ ] ,
19+ "type" : "string"
20+ } ,
21+ "age" : {
22+ "minimum" : 0 ,
23+ "type" : "integer"
24+ } ,
25+ "name" : {
26+ "$ref" : "#/definitions/name"
27+ }
28+ } ,
29+ "title" : "Person"
30+ } ,
31+
32+ definitions : {
33+ "requiredString" : {
34+ "$ref" : "required-string.yaml"
35+ } ,
36+ "string" : {
37+ "$ref" : "#/requiredString/type"
38+ } ,
39+ "name" : {
40+ "$ref" : "../definitions/name.yaml"
41+ }
42+ } ,
43+
44+ name : {
45+ "required" : [
46+ "first" ,
47+ "last"
48+ ] ,
49+ "type" : "object" ,
50+ "properties" : {
51+ "middle" : {
52+ "minLength" : {
53+ "$ref" : "#/properties/first/minLength"
54+ } ,
55+ "type" : {
56+ "$ref" : "#/properties/first/type"
57+ }
58+ } ,
59+ "prefix" : {
60+ "minLength" : 3 ,
61+ "$ref" : "#/properties/last"
62+ } ,
63+ "last" : {
64+ "$ref" : "./required-string.yaml"
65+ } ,
66+ "suffix" : {
67+ "$ref" : "#/properties/prefix" ,
68+ "type" : "string" ,
69+ "maxLength" : 3
70+ } ,
71+ "first" : {
72+ "$ref" : "../definitions/definitions.json#/requiredString"
73+ }
74+ } ,
75+ "title" : "name"
76+ } ,
77+
78+ requiredString : {
79+ "minLength" : 1 ,
80+ "type" : "string" ,
81+ "title" : "requiredString"
82+ }
83+ } ;
You can’t perform that action at this time.
0 commit comments