-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add webpack as argument to before and after options (#1760)
- Loading branch information
1 parent
31dfe22
commit 0984d4b
Showing
3 changed files
with
89 additions
and
3 deletions.
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,76 @@ | ||
'use strict'; | ||
|
||
const request = require('supertest'); | ||
const helper = require('./helper'); | ||
const config = require('./fixtures/simple-config/webpack.config'); | ||
|
||
describe('Before And After options', () => { | ||
let server; | ||
let req; | ||
|
||
beforeAll((done) => { | ||
server = helper.start( | ||
config, | ||
{ | ||
before: (app, server, compiler) => { | ||
if (!app) { | ||
throw new Error('app is not defined'); | ||
} | ||
|
||
if (!server) { | ||
throw new Error('server is not defined'); | ||
} | ||
|
||
if (!compiler) { | ||
throw new Error('compiler is not defined'); | ||
} | ||
|
||
app.get('/before/some/path', (req, res) => { | ||
res.send('before'); | ||
}); | ||
}, | ||
after: (app, server, compiler) => { | ||
if (!app) { | ||
throw new Error('app is not defined'); | ||
} | ||
|
||
if (!server) { | ||
throw new Error('server is not defined'); | ||
} | ||
|
||
if (!compiler) { | ||
throw new Error('compiler is not defined'); | ||
} | ||
|
||
app.get('/after/some/path', (req, res) => { | ||
res.send('after'); | ||
}); | ||
}, | ||
}, | ||
done | ||
); | ||
req = request(server.app); | ||
}); | ||
|
||
afterAll(helper.close); | ||
|
||
it('should handle before route', () => { | ||
return req | ||
.get('/before/some/path') | ||
.expect('Content-Type', 'text/html; charset=utf-8') | ||
.expect(200) | ||
.then((response) => { | ||
expect(response.text).toBe('before'); | ||
}); | ||
}); | ||
|
||
it('should handle after route', () => { | ||
return req | ||
.get('/after/some/path') | ||
.expect('Content-Type', 'text/html; charset=utf-8') | ||
.expect(200) | ||
.then((response) => { | ||
expect(response.text).toBe('after'); | ||
}); | ||
}); | ||
}); |
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