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