Last active
February 21, 2016 03:52
-
-
Save morrissinger/0bcfe93d4c0da9994f11 to your computer and use it in GitHub Desktop.
Testing behavior in Express
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function asyncRequest () { | |
| return new Promise((resolve, reject) => { | |
| process.nextTick(() => { | |
| resolve('Hello World'); | |
| }); | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); | |
| }); | |
| }); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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