File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,37 @@ test('Can return a function from another one', (t) => {
2222 noop ,
2323 )
2424} )
25+
26+ test ( 'options.mapReturnValues() can return any type' , ( t ) => {
27+ t . is (
28+ switchFunctional ( 0 , {
29+ mapReturnValues : ( condition : number ) => - condition ,
30+ } )
31+ . case ( true , 1 )
32+ . default ( 2 ) ,
33+ - 1 ,
34+ )
35+ } )
36+
37+ test ( 'options.mapReturnValues() can return a function' , ( t ) => {
38+ t . is (
39+ switchFunctional ( 1 , {
40+ mapReturnValues : ( condition : number ) => ( value : number ) =>
41+ condition + value ,
42+ } )
43+ . case ( true , 2 )
44+ . default ( 0 ) ,
45+ 3 ,
46+ )
47+ } )
48+
49+ test ( 'options.mapReturnValues() can take variadic parameters' , ( t ) => {
50+ t . is (
51+ switchFunctional ( 0 , {
52+ mapReturnValues : ( one : number , two : number ) => one + two ,
53+ } )
54+ . case ( true , 1 , 2 )
55+ . default ( 0 , 0 ) ,
56+ 3 ,
57+ )
58+ } )
You can’t perform that action at this time.
0 commit comments