koa-lite/test/experimental/async.js

26 lines
540 B
JavaScript
Raw Normal View History

'use strict';
/**
2015-02-16 00:47:18 +00:00
* Separate file primarily because we use `require('babel/register')`.
*/
const request = require('supertest');
2015-10-13 06:19:42 +00:00
const Koa = require('../..');
describe('.experimental=true', function () {
it('should support async functions', function (done) {
2015-10-13 06:19:42 +00:00
const app = new Koa();
app.experimental = true;
app.use(async function (next) {
const string = await Promise.resolve('asdf');
this.body = string;
});
request(app.callback())
.get('/')
.expect('asdf')
.expect(200, done);
})
})