forked from svenvc/NeoJSON
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtestFindPaths.st
More file actions
22 lines (18 loc) · 933 Bytes
/
testFindPaths.st
File metadata and controls
22 lines (18 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
testing
testFindPaths
| json paths |
json := self class exampleJSONSchema.
paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: #'$anchor' ] ].
self deny: paths isEmpty.
self assert: paths asArray equals: #((properties street_address) (#'$defs' #'country')).
self assert: ((json atPath: paths first) at: #'$anchor') equals: 'street_address'.
self assert: ((json atPath: paths second) at: #'$anchor') equals: 'country'.
paths := json findPaths: [ :object | object isDictionary and: [ (object at: #'foo') = 'bar' ] ].
self assert: paths isEmpty.
paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: #'type' ] ].
self deny: paths isEmpty.
paths do: [ :path |
self assert: (#('string' 'object') includes: ((json atPath: path) at: #'type')) ].
paths := json findPaths: [ :_ | true ].
paths do: [ :each |
self assert: (json atPath: each) notNil ]