Skip to content

Instantly share code, notes, and snippets.

@morrissinger
Last active February 21, 2016 03:52
Show Gist options
  • Save morrissinger/0bcfe93d4c0da9994f11 to your computer and use it in GitHub Desktop.
Save morrissinger/0bcfe93d4c0da9994f11 to your computer and use it in GitHub Desktop.
Testing behavior in Express
import express from "express"
import {behavior1} from "./behavior.js"
var app = express();
app.use(function (req, res, next) {
behavior1()
.then(res.send.bind(res))
.catch(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"', () => {
return behavior1().then((body) => {
Assert.equal(body, 'Hello World');
});
});
});
});
import {asyncRequest} from "./async-request-mock.js"
export function behavior1 () {
return asyncRequest();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment