2015-10-01 00:30:16 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const request = require('supertest');
|
|
|
|
|
2015-10-16 15:47:17 +02:00
|
|
|
const Koa = require('../..').server;
|
2015-10-01 00:30:16 +02:00
|
|
|
|
|
|
|
describe('ctx.state', function () {
|
|
|
|
it('should provide a ctx.state namespace', function (done) {
|
2015-10-16 15:47:17 +02:00
|
|
|
const app = new Koa();
|
2015-10-01 00:30:16 +02:00
|
|
|
|
|
|
|
app.use(function * () {
|
|
|
|
assert.deepEqual(this.state, {});
|
|
|
|
});
|
|
|
|
|
2015-10-16 15:47:17 +02:00
|
|
|
const server = app.listen();
|
|
|
|
|
|
|
|
request(server)
|
2015-10-01 00:30:16 +02:00
|
|
|
.get('/')
|
|
|
|
.expect(404)
|
|
|
|
.end(done);
|
|
|
|
});
|
|
|
|
});
|