-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* disable clasifier filter if sample has preFiltered flag * add actions to load sample
- Loading branch information
Anugerah Erlaut
authored
Apr 1, 2021
1 parent
f6f2522
commit 98687de
Showing
16 changed files
with
317 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import configureStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import fetchMock, { enableFetchMocks } from 'jest-fetch-mock'; | ||
|
||
import initialSampleState from '../../../../redux/reducers/samples/initialState'; | ||
import { SAMPLES_ERROR, SAMPLES_LOADED } from '../../../../redux/actionTypes/samples'; | ||
import { loadSamples } from '../../../../redux/actions/samples'; | ||
|
||
enableFetchMocks(); | ||
|
||
const mockStore = configureStore([thunk]); | ||
|
||
describe('loadSample action', () => { | ||
const experimentId = '1234'; | ||
|
||
const initialState = { | ||
samples: { | ||
...initialSampleState, | ||
}, | ||
}; | ||
|
||
const response = new Response( | ||
JSON.stringify( | ||
{ | ||
samples: { | ||
ids: ['sample-1', 'sample-2'], | ||
'sample-1': { name: 'sample-1' }, | ||
'sample-2': { name: 'sample-2' }, | ||
}, | ||
}, | ||
), | ||
); | ||
|
||
fetchMock.resetMocks(); | ||
fetchMock.doMock(); | ||
fetchMock.mockResolvedValue(response); | ||
|
||
it('Dispatches event correctly', async () => { | ||
const store = mockStore(initialState); | ||
await store.dispatch(loadSamples(experimentId)); | ||
|
||
// LOAD SAMPLE | ||
const action1 = store.getActions()[0]; | ||
expect(action1.type).toEqual(SAMPLES_LOADED); | ||
}); | ||
|
||
it('Dispatches error correctly', async () => { | ||
fetchMock.mockReject(new Error('Failed fetching samples')); | ||
|
||
const store = mockStore(initialState); | ||
await store.dispatch(loadSamples(experimentId)); | ||
|
||
// LOAD SAMPLE | ||
const action1 = store.getActions()[0]; | ||
expect(action1.type).toEqual(SAMPLES_ERROR); | ||
}); | ||
}); |
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.