2014-12-18 02:06:45 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-12-18 02:06:45 +00:00
|
|
|
/**
|
2015-02-16 00:47:18 +00:00
|
|
|
* Separate file primarily because we use `require('babel/register')`.
|
2014-12-18 02:06:45 +00:00
|
|
|
*/
|
|
|
|
|
2015-10-05 18:23:47 +00:00
|
|
|
const request = require('supertest');
|
|
|
|
const koa = require('../..');
|
2014-12-18 02:06:45 +00:00
|
|
|
|
|
|
|
describe('.experimental=true', function () {
|
|
|
|
it('should support async functions', function (done) {
|
2015-10-05 18:23:47 +00:00
|
|
|
const app = koa();
|
2014-12-18 02:06:45 +00:00
|
|
|
app.experimental = true;
|
|
|
|
app.use(async function (next) {
|
2015-10-05 18:23:47 +00:00
|
|
|
const string = await Promise.resolve('asdf');
|
2014-12-18 02:06:45 +00:00
|
|
|
this.body = string;
|
|
|
|
});
|
|
|
|
|
|
|
|
request(app.callback())
|
|
|
|
.get('/')
|
|
|
|
.expect('asdf')
|
|
|
|
.expect(200, done);
|
|
|
|
})
|
|
|
|
})
|