11'use strict' ;
22
33const common = require ( '../../common' ) ;
4- const test_promise = require ( `./build/${ common . buildType } /test_promise` ) ;
4+
5+ // This tests the promise-related n-api calls
6+
57const assert = require ( 'assert' ) ;
8+ const test_promise = require ( `./build/${ common . buildType } /test_promise` ) ;
69
710// A resolution
811{
912 const expected_result = 42 ;
1013 const promise = test_promise . createPromise ( ) ;
1114 promise . then (
1215 common . mustCall ( function ( result ) {
13- assert . strictEqual ( result , expected_result ,
14- `promise resolved as expected, received ${ result } ` ) ;
16+ assert . strictEqual ( result , expected_result ) ;
1517 } ) ,
1618 common . mustNotCall ( ) ) ;
1719 test_promise . concludeCurrentPromise ( expected_result , true ) ;
@@ -24,23 +26,24 @@ const assert = require('assert');
2426 promise . then (
2527 common . mustNotCall ( ) ,
2628 common . mustCall ( function ( result ) {
27- assert . strictEqual ( result , expected_result ,
28- `promise rejected as expected, received ${ result } ` ) ;
29+ assert . strictEqual ( result , expected_result ) ;
2930 } ) ) ;
3031 test_promise . concludeCurrentPromise ( expected_result , false ) ;
3132}
3233
3334// Chaining
34- const promise = test_promise . createPromise ( ) ;
35- promise . then (
36- common . mustCall ( function ( result ) {
37- assert . strictEqual ( result , 'chained answer' ,
38- 'resolving with a promise chains properly' ) ;
39- } ) ,
40- common . mustNotCall ( ) ) ;
41- test_promise . concludeCurrentPromise ( Promise . resolve ( 'chained answer' ) , true ) ;
35+ {
36+ const expected_result = 'chained answer' ;
37+ const promise = test_promise . createPromise ( ) ;
38+ promise . then (
39+ common . mustCall ( function ( result ) {
40+ assert . strictEqual ( result , expected_result ) ;
41+ } ) ,
42+ common . mustNotCall ( ) ) ;
43+ test_promise . concludeCurrentPromise ( Promise . resolve ( 'chained answer' ) , true ) ;
44+ }
4245
43- assert . strictEqual ( test_promise . isPromise ( promise ) , true ) ;
46+ assert . strictEqual ( test_promise . isPromise ( test_promise . createPromise ( ) ) , true ) ;
4447assert . strictEqual ( test_promise . isPromise ( Promise . reject ( - 1 ) ) , true ) ;
4548assert . strictEqual ( test_promise . isPromise ( 2.4 ) , false ) ;
4649assert . strictEqual ( test_promise . isPromise ( 'I promise!' ) , false ) ;
0 commit comments