File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ // @flow strict
2
+
3
+ import { expect } from 'chai' ;
4
+ import { describe , it } from 'mocha' ;
5
+
6
+ import { addPath , pathToArray } from '../Path' ;
7
+ import { type Path } from '../Path' ;
8
+
9
+ describe ( 'Path' , ( ) => {
10
+ it ( 'can add a new key to an existing Path' , ( ) => {
11
+ const first : Path = { prev : undefined , key : 1 } ;
12
+ const second = addPath ( first , 'two' ) ;
13
+ expect ( second . prev ) . to . equal ( first ) ;
14
+ expect ( second . key ) . to . equal ( 'two' ) ;
15
+ } ) ;
16
+
17
+ it ( 'can convert a Path to an array of its keys' , ( ) => {
18
+ const root : Path = { prev : undefined , key : 0 } ;
19
+ const first = { prev : root , key : 'one' } ;
20
+ const second = { prev : first , key : 2 } ;
21
+ expect ( pathToArray ( second ) )
22
+ . to . be . an ( 'array' )
23
+ . that . deep . equals ( [ 0 , 'one' , 2 ] ) ;
24
+ } ) ;
25
+ } ) ;
You can’t perform that action at this time.
0 commit comments