File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,15 @@ describe('[ curry2 ]', function () {
1515 expect ( addWith5 ( 3 ) ) . to . eql ( 8 )
1616 expect ( addWith5 ( 5 ) ) . to . eql ( 10 )
1717 } )
18+
19+ it ( 'curry2 에 함수가 아닌 인자를 입력하는 경우 TypeError 가 발생할 수 있다.' , ( ) => {
20+ const unknown = curry2 ( 'abc' )
21+
22+ expect ( unknown ) . to . be . a ( 'function' )
23+ expect ( unknown ( 1 ) ) . to . be . a ( 'function' )
24+ expect ( ( ) => unknown ( 1 ) ( 2 ) ) . to . throw ( TypeError , 'Function.prototype.apply was called on abc, which is a string and not a function' )
25+ unknown ( 1 ) ( 2 )
26+ } )
1827} )
1928
2029describe ( '[ pipe ]' , function ( ) {
@@ -45,4 +54,13 @@ describe('[ pipe ]', function () {
4554 await p1 . then ( result => expect ( result ) . to . eql ( 4 ) )
4655 await p2 . then ( result => expect ( result ) . to . eql ( 6 ) )
4756 } )
57+
58+ it ( 'pipe 중간에 함수가 아닌 인자가 들어가는 경우 TypeError 가 발생할 수 있다.' , ( ) => {
59+ const f = pipe ( add1 , mul2 , 3 )
60+
61+ expect ( f ) . to . be . a ( 'function' )
62+ expect ( ( ) => f ( 1 ) ) . to . throw ( TypeError , 'f is not a function' )
63+ expect ( ( ) => f ( 2 ) ) . to . throw ( TypeError , 'f is not a function' )
64+ f ( 1 )
65+ } )
4866} )
You can’t perform that action at this time.
0 commit comments