-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Next): Add jest test without server running
- Loading branch information
Showing
6 changed files
with
101 additions
and
9 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 |
---|---|---|
|
@@ -9,3 +9,5 @@ coverage | |
tmp | ||
.env | ||
dist | ||
|
||
public/resized |
This file was deleted.
Oops, something went wrong.
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.16.0 |
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 |
---|---|---|
@@ -1,17 +1,23 @@ | ||
const fetch = require('node-fetch'); | ||
import { createMocks } from 'node-mocks-http'; | ||
|
||
import handleGalleryEndpoint from '../../../pages/api/galleryList'; | ||
|
||
describe('Gallery API', () => { | ||
const utils = require('../../../../api/server/plugins/utils'); | ||
const port = utils.config.get('nextPort'); | ||
|
||
test('* Validate Gallery List route', async () => { | ||
const endpoint = '/galleryList'; | ||
const url = `http://localhost:${port}/api${endpoint}`; | ||
const { req, res } = createMocks({ | ||
method: 'GET', | ||
query: { | ||
animal: 'dog', | ||
}, | ||
}); | ||
|
||
const response = await fetch(url); | ||
expect(response.status).toBe(200); | ||
await handleGalleryEndpoint(req, res); | ||
expect(res._getStatusCode()).toBe(200); | ||
|
||
const result = await response.json(); | ||
const result = JSON.parse(res._getData()); | ||
expect(result.galleries.includes('demo')).toBeTruthy(); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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