Skip to content

Instantly share code, notes, and snippets.

@morrissinger
Last active February 21, 2016 03:55
Show Gist options
  • Save morrissinger/6f638c04725d38155a88 to your computer and use it in GitHub Desktop.
Save morrissinger/6f638c04725d38155a88 to your computer and use it in GitHub Desktop.
Testing behavior in Koa
import koa from "koa"
import {behavior1} from "./behavior.js"
var app = koa();
app.use(function* (next) {
this.body = yield behavior1();
return yield next;
});
app.listen(3000);
export function asyncRequest () {
return new Promise((resolve, reject) => {
process.nextTick(() => {
resolve('Hello World');
});
});
};
import Assert from "assert"
import {behavior1} from "./behavior.js"
describe('behavior', () => {
describe('behavior1', () => {
it('returns "Hello World"', function* () {
let body = yield behavior1();
Assert.equal(body, 'Hello World');
});
});
});
import {asyncRequest} from "./async-request-mock.js"
export function* behavior1 () {
return yield asyncRequest();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment