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

feat(drugs tests): replaced constants with axios http response

parent 7c759fae
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"
export const HTTP_OK = 200;
export const HTTP_NOT_FOUND = 404;
import { HttpStatusCode } from 'axios';
import { PROJECT_ID } from '@/constants/mapId';
import { drugsFixture } from '@/models/fixtures/drugFixtures';
import { HTTP_NOT_FOUND, HTTP_OK } from '@/constants/httpResponses';
import { mockNetworkResponse } from '@/utils/mockNetworkResponse';
import {
ToolkitStoreWithSingleSlice,
......@@ -33,7 +33,7 @@ describe('drugs reducer', () => {
it('should update store after succesfull getDrugs query', async () => {
mockedAxiosClient
.onGet(`projects/${PROJECT_ID}/drugs:search?query=${SEARCH_QUERY}`)
.reply(HTTP_OK, drugsFixture);
.reply(HttpStatusCode.Ok, drugsFixture);
const { type } = await store.dispatch(getDrugs(SEARCH_QUERY));
const { data, loading, error } = store.getState().drugs;
......@@ -47,7 +47,7 @@ describe('drugs reducer', () => {
it('should update store after failed getDrugs query', async () => {
mockedAxiosClient
.onGet(`projects/${PROJECT_ID}/drugs:search?query=${SEARCH_QUERY}`)
.reply(HTTP_NOT_FOUND, []);
.reply(HttpStatusCode.NotFound, []);
const { type } = await store.dispatch(getDrugs(SEARCH_QUERY));
const { data, loading, error } = store.getState().drugs;
......@@ -61,7 +61,7 @@ describe('drugs reducer', () => {
it('should update store on loading getDrugs query', async () => {
mockedAxiosClient
.onGet(`projects/${PROJECT_ID}/drugs:search?query=${SEARCH_QUERY}`)
.reply(HTTP_OK, drugsFixture);
.reply(HttpStatusCode.Ok, drugsFixture);
const drugsPromise = store.dispatch(getDrugs(SEARCH_QUERY));
......
import { HttpStatusCode } from 'axios';
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,
......@@ -22,7 +22,7 @@ describe('drugs thunks', () => {
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);
.reply(HttpStatusCode.Ok, drugsFixture);
const { payload } = await store.dispatch(getDrugs(SEARCH_QUERY));
expect(payload).toEqual(drugsFixture);
......@@ -30,7 +30,7 @@ describe('drugs thunks', () => {
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' });
.reply(HttpStatusCode.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