2014-11-18 08:54:14 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-05 18:23:47 +00:00
|
|
|
const request = require('supertest');
|
|
|
|
const assert = require('assert');
|
2015-10-13 06:19:42 +00:00
|
|
|
const Koa = require('../..');
|
2014-11-18 08:54:14 +00:00
|
|
|
|
2015-10-25 07:54:57 +00:00
|
|
|
describe('ctx.state', () => {
|
2017-05-11 03:30:32 +00:00
|
|
|
it('should provide a ctx.state namespace', () => {
|
2015-10-13 06:19:42 +00:00
|
|
|
const app = new Koa();
|
2014-11-18 08:54:14 +00:00
|
|
|
|
2015-10-25 07:54:57 +00:00
|
|
|
app.use(ctx => {
|
2015-10-14 00:45:18 +00:00
|
|
|
assert.deepEqual(ctx.state, {});
|
2014-11-18 08:54:14 +00:00
|
|
|
});
|
|
|
|
|
2015-10-05 18:23:47 +00:00
|
|
|
const server = app.listen();
|
2014-11-18 08:54:14 +00:00
|
|
|
|
2017-05-11 03:30:32 +00:00
|
|
|
return request(server)
|
2015-10-28 07:53:49 +00:00
|
|
|
.get('/')
|
2017-05-11 03:30:32 +00:00
|
|
|
.expect(404);
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
|
|
|
});
|