沈斌
2018-07-12 bd67fdc558c8568999a538d2a8e43b59ceb06756
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require('./spec_helper');
var expressPromise = require('..');
 
describe('recursive', function() {
  it('should resolve a promise that resolves with a promise', function(done) {
    var res = {
      json: function(body) {
        body.a.should.equal('hi');
        done();
      }
    };
 
    expressPromise({methods: ['json']})(null, res);
    function async(callback) {
      callback(null, 'hi');
    }
    function doubleAsync(callback) {
      callback(null, async.promise());
    }
 
    res.json({
      a: doubleAsync.promise()
    });
 
  });
 
});