forked from antongolub/reqresnext
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes antongolub#29 - this adds a new type of test showing what happens when req and res are used in conjunction with express - added a noop for unpipe, which fixes the broken test
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import reqresnext from '../../main/js/reqresnext' | ||
import express from 'express' | ||
|
||
describe('express', () => { | ||
it('reqresnext correctly 404s when no route handlers are available', (done) => { | ||
const { req, res } = reqresnext({ | ||
method: 'GET', | ||
url: '/' | ||
}) | ||
|
||
const app = express() | ||
|
||
res.on('finish', () => { | ||
expect(res.statusCode).toBe(404) | ||
done() | ||
}) | ||
|
||
app(req, res) | ||
}) | ||
|
||
it('route handler is called when available', (done) => { | ||
const { req, res } = reqresnext({ | ||
method: 'GET', | ||
url: '/' | ||
}, {}) | ||
|
||
const app = express() | ||
app.get('/', (_req, _res) => { | ||
return _res.sendStatus(200) | ||
}) | ||
|
||
res.on('finish', () => { | ||
expect(res.statusCode).toBe(200) | ||
done() | ||
}) | ||
|
||
app(req, res) | ||
}) | ||
}) |