-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(next-tinacms-github): sends 500 with message if signing key is mi…
…ssing
- Loading branch information
1 parent
4e89438
commit 002ce35
Showing
2 changed files
with
37 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,31 @@ | ||
import { apiProxy } from './proxy' | ||
|
||
describe('apiProxy', () => { | ||
describe('without a signing key', () => { | ||
it('responds with status 500', async () => { | ||
// @ts-ignore That's the point of the test. | ||
const handler = apiProxy(undefined) | ||
const req = {} | ||
const res = new ResStub() | ||
|
||
await handler(req, res) | ||
|
||
expect(res.status).toHaveBeenCalledWith(500) | ||
}) | ||
it('sends JSON response', async () => { | ||
// @ts-ignore That's the point of the test. | ||
const handler = apiProxy(undefined) | ||
const req = {} | ||
const res = new ResStub() | ||
|
||
await handler(req, res) | ||
|
||
expect(res.json).toHaveBeenCalled() | ||
}) | ||
}) | ||
}) | ||
|
||
class ResStub { | ||
status = jest.fn(() => this) | ||
json = jest.fn() | ||
} |
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