Skip to content
Snippets Groups Projects
Commit 7c759fae authored by Tadeusz Miesiąc's avatar Tadeusz Miesiąc
Browse files

test: added missing tests

parent 4935a516
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!20Resolve MIN-57 "Feature/ connect drug search query"
Pipeline #79025 passed
import { PROJECT_ID } from '@/constants/mapId';
import { drugsFixture } from '@/models/fixtures/drugFixtures';
import { HTTP_OK } from '@/constants/httpResponses';
import { mockNetworkResponse } from '@/utils/mockNetworkResponse';
import {
ToolkitStoreWithSingleSlice,
createStoreInstanceUsingSliceReducer,
} from '@/utils/createStoreInstanceUsingSliceReducer';
import { getDrugs } from './drugs.thunks';
import drugsReducer from './drugs.slice';
import { DrugsState } from './drugs.types';
const mockedAxiosClient = mockNetworkResponse();
const SEARCH_QUERY = 'aspirin';
describe('drugs thunks', () => {
let store = {} as ToolkitStoreWithSingleSlice<DrugsState>;
beforeEach(() => {
store = createStoreInstanceUsingSliceReducer('drugs', drugsReducer);
});
describe('getDrugs', () => {
it('should return data when data response from API is valid', async () => {
mockedAxiosClient
.onGet(`projects/${PROJECT_ID}/drugs:search?query=${SEARCH_QUERY}`)
.reply(HTTP_OK, drugsFixture);
const { payload } = await store.dispatch(getDrugs(SEARCH_QUERY));
expect(payload).toEqual(drugsFixture);
});
it('should return undefined when data response from API is not valid ', async () => {
mockedAxiosClient
.onGet(`projects/${PROJECT_ID}/drugs:search?query=${SEARCH_QUERY}`)
.reply(HTTP_OK, { randomProperty: 'randomValue' });
const { payload } = await store.dispatch(getDrugs(SEARCH_QUERY));
expect(payload).toEqual(undefined);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment