This repository has been archived by the owner on Dec 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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
4 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,5 +1,24 @@ | ||
import axios from 'axios' | ||
import MockAdapter from 'axios-mock-adapter' | ||
|
||
import authenticate from '../src/helpers/authenticate' | ||
|
||
describe('authenticate', async () => { | ||
it('should fetch an access token', async () => {}) | ||
const mock = new MockAdapter(axios) | ||
|
||
const url = 'https://account.demandware.com/dw/oauth2/access_token' | ||
const credentials = { clientId: 'test', clientPassword: 'test' } | ||
|
||
describe('authenticate', () => { | ||
it('should fetch an access token', async () => { | ||
expect.assertions(1) | ||
const mockResponse = { access_token: 'token' } | ||
mock.onPost(url).reply(200, mockResponse) | ||
await expect(authenticate(credentials)).resolves.toEqual(mockResponse.access_token) | ||
}) | ||
|
||
it('should fails with an error', async () => { | ||
expect.assertions(1) | ||
mock.onPost(url).networkError() | ||
await expect(authenticate(credentials)).rejects.toThrow() | ||
}) | ||
}) |