-
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.
feat(server.ts): add server to handle incoming requests
- Loading branch information
Fredrik Makila
committed
Sep 13, 2020
1 parent
3422a4d
commit 8c8adf3
Showing
2 changed files
with
22 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import app from '../app'; | ||
|
||
jest.mock('../app', () => ({ | ||
listen: jest.fn((port: number, fn: () => void) => fn()), | ||
get: () => 424242 | ||
})); | ||
const mockApp = app as jest.Mocked<typeof app>; | ||
|
||
describe('server', () => { | ||
it('should listen to port provided by the app', () => { | ||
require('../server'); | ||
expect(mockApp.listen).toHaveBeenCalledWith(424242, expect.any(Function)); | ||
}); | ||
}); |
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,8 @@ | ||
import app from './app'; | ||
import { info } from './logger'; | ||
|
||
const server = app.listen(app.get('port'), () => { | ||
info(`Server is running on port ${app.get('port')}`); | ||
}); | ||
|
||
export default server; |