-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: init request and response tests
- Loading branch information
1 parent
ee36bd5
commit 84dc522
Showing
6 changed files
with
44 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { axiosMock, mockAxios } from '../mocks/axios'; | ||
|
||
describe('test request interceptor', () => { | ||
it('tests against specified methods', async () => { | ||
const axios = mockAxios({ | ||
// only cache post methods | ||
methods: ['post'] | ||
}); | ||
|
||
const response = await axios.get(axiosMock.url); | ||
const cacheKey = await axios.generateKey(response.config); | ||
const cache = await axios.storage.get(cacheKey); | ||
|
||
expect(cache.state).toBe('empty'); | ||
}); | ||
|
||
it('tests specified methods', async () => { | ||
const axios = mockAxios({ | ||
// only cache get methods | ||
methods: ['get'] | ||
}); | ||
|
||
const response = await axios.get(axiosMock.url); | ||
const cacheKey = await axios.generateKey(response.config); | ||
const cache = await axios.storage.get(cacheKey); | ||
|
||
expect(cache.state).toBe('cached'); | ||
}); | ||
}); |
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,7 @@ | ||
// import { mockAxios } from '../mocks/axios'; | ||
|
||
describe('test request interceptor', () => { | ||
it('tests', () => { | ||
//const axios = mockAxios(); | ||
}); | ||
}); |
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