File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,37 @@ test("forEachSeries", {
164164 }
165165} ) ;
166166
167+ test ( "nfcall" , {
168+ "when function calls callback with error then promise is rejected" : function ( ) {
169+ return promises . nfcall ( function ( callback ) {
170+ callback ( new Error ( "failure" ) ) ;
171+ } ) . then (
172+ function ( result ) {
173+ assert . fail ( "Expected rejection" ) ;
174+ } ,
175+ function ( error ) {
176+ assert . strictEqual ( error . message , "failure" ) ;
177+ }
178+ ) ;
179+ } ,
180+
181+ "when function calls callback with value then promise is resolved" : function ( ) {
182+ return promises . nfcall ( function ( callback ) {
183+ callback ( null , "success" ) ;
184+ } ) . then ( function ( result ) {
185+ assert . strictEqual ( result , "success" ) ;
186+ } ) ;
187+ } ,
188+
189+ "function is called with passed arguments" : function ( ) {
190+ return promises . nfcall ( function ( a , b , callback ) {
191+ callback ( null , [ "success" , a , b ] ) ;
192+ } , "a" , "b" ) . then ( function ( result ) {
193+ assert . deepStrictEqual ( result , [ "success" , "a" , "b" ] ) ;
194+ } ) ;
195+ }
196+ } ) ;
197+
167198test ( "props" , {
168199 "props({}) resolve to {}" : function ( ) {
169200 return promises . props ( { } ) . then ( function ( result ) {
You can’t perform that action at this time.
0 commit comments