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 9f05376
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/mock_context.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict';

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

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

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

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

yield sleep(2000);
const content = fs.readFileSync(path.join(__dirname, './fixtures/demo/logs/demo/common-error.log'), 'utf-8');
console.log('####', content);
});

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

0 comments on commit 9f05376

Please sign in to comment.