-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change request response in
/status
endpoint (#2056)
* fix: change request response in `status` endpoint * feat: add test for `statusPageMiddleware`
- Loading branch information
1 parent
f621ae4
commit 22cc556
Showing
3 changed files
with
30 additions
and
9 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/cli-server-api/src/__tests__/statusPageMiddleware.test.ts
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,20 @@ | ||
import http from 'http'; | ||
import statusPageMiddleware from './../statusPageMiddleware'; | ||
|
||
describe('statusPageMiddleware', () => { | ||
it('should set headers and end the response', () => { | ||
process.cwd = () => '/mocked/path'; | ||
|
||
const res: http.ServerResponse = { | ||
setHeader: jest.fn(), | ||
end: jest.fn(), | ||
} as any; | ||
|
||
const mockReq: http.IncomingMessage = {} as any; | ||
statusPageMiddleware(mockReq, res); | ||
|
||
// We're strictly checking response here, because React Native is strongly depending on this response. Changing the response might be a breaking change. | ||
expect(res.setHeader).toHaveBeenCalledWith('Project-Root', '/mocked/path'); | ||
expect(res.end).toHaveBeenCalledWith('packager-status:running'); | ||
}); | ||
}); |
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