File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "plugins" : [
3
+ " transform-async-to-generator"
4
+ ]
5
+ }
Original file line number Diff line number Diff line change 7
7
"test" : " test"
8
8
},
9
9
"scripts" : {
10
- "test" : " mocha -R spec test/**/*.js"
10
+ "test" : " mocha -R spec --require babel-register test/**/*.js"
11
11
},
12
12
"repository" : {
13
13
"type" : " git" ,
26
26
},
27
27
"homepage" : " https://github.com/Functional-JavaScript/FunctionalES#readme" ,
28
28
"devDependencies" : {
29
+ "babel-cli" : " ^6.26.0" ,
30
+ "babel-plugin-transform-async-to-generator" : " ^6.24.1" ,
31
+ "babel-register" : " ^6.26.0" ,
29
32
"chai" : " ^4.1.2" ,
30
33
"mocha" : " ^5.1.0"
31
34
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ describe('[ curry2 ]', function () {
19
19
20
20
describe ( '[ pipe ]' , function ( ) {
21
21
const add1 = a => a + 1
22
+ const add1P = a => new Promise ( resolve => setTimeout ( ( ) => resolve ( a + 1 ) , 1000 ) )
22
23
const mul2 = a => a * 2
23
24
24
25
it ( 'pipe 는 인자로 받은 함수들을 순차적으로 실행하는 함수를 반환한다.' , ( ) => {
@@ -28,4 +29,20 @@ describe('[ pipe ]', function () {
28
29
expect ( f ( 1 ) ) . to . eql ( 4 )
29
30
expect ( f ( 2 ) ) . to . eql ( 6 )
30
31
} )
32
+
33
+ it ( 'pipe 에 promise 를 반환하는 비동키 함수가 포함되는 경우 pipe 함수는 인자로 들어온 함수를 순차적으로 실행하지만 promise 를 반환한다.' , async ( ) => {
34
+ this . timeout ( 2000 )
35
+
36
+ const fP = pipe ( add1P , mul2 )
37
+ expect ( fP ) . to . be . a ( 'function' )
38
+
39
+ const p1 = fP ( 1 )
40
+ const p2 = fP ( 2 )
41
+
42
+ expect ( p1 ) . to . be . a ( 'Promise' )
43
+ expect ( p2 ) . to . be . a ( 'Promise' )
44
+
45
+ await p1 . then ( result => expect ( result ) . to . eql ( 4 ) )
46
+ await p2 . then ( result => expect ( result ) . to . eql ( 6 ) )
47
+ } )
31
48
} )
You can’t perform that action at this time.
0 commit comments