-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
3,282 additions
and
53 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,4 @@ | ||
module.exports = { | ||
plugins: ['@babel/plugin-transform-runtime'], | ||
presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react'], | ||
}; |
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 @@ | ||
require('jest-fetch-mock').enableMocks(); |
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,17 @@ | ||
import { Dribbble } from '..'; | ||
import 'jest-fetch-mock'; | ||
|
||
describe('dribbble', () => { | ||
beforeEach(() => { | ||
fetchMock.resetMocks(); | ||
}); | ||
|
||
test('fetch project data', async () => { | ||
const mockData = { name: 'Stefan Mansson' }; | ||
fetchMock.mockResponseOnce(JSON.stringify(mockData), { status: 200 }); | ||
|
||
const dribbble = new Dribbble({ authToken: '1234' }); | ||
|
||
expect(await dribbble.user.get()).toEqual(mockData); | ||
}); | ||
}); |
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,22 @@ | ||
import Request from '../Request'; | ||
import 'jest-fetch-mock'; | ||
|
||
describe('Request', () => { | ||
beforeEach(() => { | ||
fetchMock.resetMocks(); | ||
}); | ||
|
||
test('builds and fetches from url', async () => { | ||
fetchMock.mockResponseOnce(JSON.stringify({}), { status: 200 }); | ||
|
||
await Request.fetch({ url: '/user/projects', method: 'GET' }); | ||
|
||
expect(fetchMock.mock.calls[0][0]).toEqual(Request.buildURL('/user/projects')); | ||
}); | ||
|
||
test('fetch throws with error status', async () => { | ||
fetchMock.mockResponseOnce(JSON.stringify({}), { status: 400 }); | ||
|
||
await expect(Request.fetch({ url: '/user/projects', method: 'GET' })).rejects.toThrow(); | ||
}); | ||
}); |
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
Oops, something went wrong.