File tree 1 file changed +36
-0
lines changed 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai' ;
2
+ import { describe , it } from 'mocha' ;
3
+
4
+ import { addPath , pathToArray } from '../Path' ;
5
+
6
+ describe ( 'Path' , ( ) => {
7
+ it ( 'can create a Path' , ( ) => {
8
+ const first = addPath ( undefined , 1 , 'First' ) ;
9
+
10
+ expect ( first ) . to . deep . equal ( {
11
+ prev : undefined ,
12
+ key : 1 ,
13
+ typename : 'First' ,
14
+ } ) ;
15
+ } ) ;
16
+
17
+ it ( 'can add a new key to an existing Path' , ( ) => {
18
+ const first = addPath ( undefined , 1 , 'First' ) ;
19
+ const second = addPath ( first , 'two' , 'Second' ) ;
20
+
21
+ expect ( second ) . to . deep . equal ( {
22
+ prev : first ,
23
+ key : 'two' ,
24
+ typename : 'Second' ,
25
+ } ) ;
26
+ } ) ;
27
+
28
+ it ( 'can convert a Path to an array of its keys' , ( ) => {
29
+ const root = addPath ( undefined , 0 , 'Root' ) ;
30
+ const first = addPath ( root , 'one' , 'First' ) ;
31
+ const second = addPath ( first , 2 , 'Second' ) ;
32
+
33
+ const path = pathToArray ( second ) ;
34
+ expect ( path ) . to . deep . equal ( [ 0 , 'one' , 2 ] ) ;
35
+ } ) ;
36
+ } ) ;
You can’t perform that action at this time.
0 commit comments