koa-lite/test/experimental/async.js

26 lines
537 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('../..');
2015-10-12 20:36:41 +00:00
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;
2015-10-12 20:36:41 +00:00
app.use(async function (next){
const string = await Promise.resolve('asdf');
this.body = string;
});
request(app.callback())
.get('/')
.expect('asdf')
.expect(200, done);
2015-10-12 20:36:41 +00:00
});
});