Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 committed Mar 27, 2018
1 parent f0f12f1 commit c638ffc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions test/fixtures/demo/app/controller/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

exports.get = function* () {
this.body = this.user;
};
Expand Down
24 changes: 17 additions & 7 deletions test/mock_context.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

const assert = require('assert');
const mm = require('..');
const fs = require('fs');
const path = require('path');
const sleep = require('mz-modules/sleep');

describe('test/mock_context.test.js', () => {
let app;
Expand All @@ -14,20 +17,27 @@ describe('test/mock_context.test.js', () => {
after(() => app.close());
afterEach(mm.restore);

it('should work on GET with user login', () => {
it.only('should work on GET with user login', async () => {
const ctx = app.mockContext({
user: {
foo: 'bar',
},
});

assert(ctx.user.foo === 'bar');
return app.httpRequest()
.get('/user')
.expect(200)
.expect({
foo: 'bar',
});

try {
await app.httpRequest()
.get('/user')
.expect(200)
.expect({
foo: 'bar',
});
} catch (err) {
console.log(err);
}
const log = fs.readFileSync(path.join(__dirname, './fixtures/demo/logs/demo/common-error.log'), 'utf-8');
console.log(log);
});

it('should work on POST with user login', () => {
Expand Down

0 comments on commit c638ffc

Please sign in to comment.