沈斌
2018-07-10 c347a3cf58b27a1ab267517fa9effbb7d477626b
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()
    });
 
  });
 
});