Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/specs/screens/home/reducers/homeReducer.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actionCreators, onSuccessful } from '@/shared/base';
import { actionTypes, onSuccessful } from '@/shared/base';
import { homeReducer } from '@/screens/home/reducers';

describe('home/reducers/homeReducer tests', () => {
Expand All @@ -19,7 +19,7 @@ describe('home/reducers/homeReducer tests', () => {
const initialState = { loading: true, reservations: [] };

const action = {
type: onSuccessful(actionCreators.GET_RESERVATIONS),
type: onSuccessful(actionTypes.GET_RESERVATIONS),
response,
};

Expand Down
18 changes: 9 additions & 9 deletions frontend/specs/screens/home/sagas/cancelReservation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { call } from 'redux-saga/effects';
import { throwError } from 'redux-saga-test-plan/providers';

import {
actionCreators,
actionTypes,
onCancellation,
onFailure,
onSuccessful,
Expand All @@ -18,7 +18,7 @@ describe('cancelReservation Saga', () => {
let scenario;

const action = {
type: actionCreators.DELETE_RESERVATION,
type: actionTypes.DELETE_RESERVATION,
reservationId: 999,
};
const expectedRequestParams = { reservationId: action.reservationId };
Expand Down Expand Up @@ -56,13 +56,13 @@ describe('cancelReservation Saga', () => {
[call(confirmation, action.reservationId), true],
])
.put({
type: onSuccessful(actionCreators.DELETE_RESERVATION),
type: onSuccessful(actionTypes.DELETE_RESERVATION),
response: {
data: expectedApiResponse,
},
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType: 'success',
message: 'Reservation cancelled.',
})
Expand All @@ -73,7 +73,7 @@ describe('cancelReservation Saga', () => {
return scenario
.provide([[call(confirmation, action.reservationId), false]])
.put({
type: onCancellation(actionCreators.REJECT_CONFIRMATION_MODAL),
type: onCancellation(actionTypes.REJECT_CONFIRMATION_MODAL),
})
.silentRun();
});
Expand All @@ -98,12 +98,12 @@ describe('cancelReservation Saga', () => {
],
])
.put({
type: onFailure(actionCreators.DELETE_RESERVATION),
type: onFailure(actionTypes.DELETE_RESERVATION),
alertType: 'danger',
message: expectedErrMessage,
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType: 'danger',
message: expectedErrMessage,
})
Expand All @@ -122,12 +122,12 @@ describe('cancelReservation Saga', () => {
[call(confirmation, action.reservationId), true],
])
.put({
type: onFailure(actionCreators.DELETE_RESERVATION),
type: onFailure(actionTypes.DELETE_RESERVATION),
alertType: 'danger',
message: expectedErrMessage,
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType: 'danger',
message: expectedErrMessage,
})
Expand Down
8 changes: 4 additions & 4 deletions frontend/specs/screens/home/sagas/getAllReservations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expectSaga } from 'redux-saga-test-plan';
import { call } from 'redux-saga/effects';
import { throwError } from 'redux-saga-test-plan/providers';

import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, getExistingReservationsQuery } from '@/shared/graphql';

import getAllReservations from '@/screens/home/sagas/getAllReservations';
Expand All @@ -11,7 +11,7 @@ describe('getAllReservations Saga', () => {
let scenario;

const action = {
type: actionCreators.GET_RESERVATIONS,
type: actionTypes.GET_RESERVATIONS,
};
const expectedRequestParams = {};

Expand Down Expand Up @@ -77,7 +77,7 @@ describe('getAllReservations Saga', () => {
message: expectedErrMessage,
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
Expand All @@ -101,7 +101,7 @@ describe('getAllReservations Saga', () => {
message: expectedErrMessage,
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actionCreators, onSuccessful } from '@/shared/base';
import { actionTypes, onSuccessful } from '@/shared/base';

import { newReducer } from '@/screens/reservations/reducers';

Expand All @@ -17,7 +17,7 @@ describe('reservations/reducers/newReducer tests', () => {
const initialState = { loading: true, roomIds: [] };

const action = {
type: onSuccessful(actionCreators.GET_ROOM_IDS),
type: onSuccessful(actionTypes.GET_ROOM_IDS),
response,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { expectSaga } from 'redux-saga-test-plan';
import { call } from 'redux-saga/effects';
import { throwError } from 'redux-saga-test-plan/providers';

import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, getRoomIdsQuery } from '@/shared/graphql';

import getAllRoomIds from '@/screens/reservations/sagas/getAllRoomIds';

describe('getAllRoomIds Saga', () => {
let scenario;

const action = { type: actionCreators.GET_ROOM_IDS };
const action = { type: actionTypes.GET_ROOM_IDS };
const expectedRequestParams = {};
const mockRooms = [{ id: 'room1' }, { id: 'room2' }, { id: 'room3' }];

Expand Down Expand Up @@ -72,7 +72,7 @@ describe('getAllRoomIds Saga', () => {
message: expectedErrMessage,
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
Expand All @@ -98,7 +98,7 @@ describe('getAllRoomIds Saga', () => {
message: expectedErrMessage,
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
Expand Down
14 changes: 7 additions & 7 deletions frontend/specs/screens/reservations/sagas/newReservation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expectSaga } from 'redux-saga-test-plan';
import { call } from 'redux-saga/effects';
import { throwError } from 'redux-saga-test-plan/providers';

import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, createReservationMutation } from '@/shared/graphql';

import newReservation from '@/screens/reservations/sagas/newReservation';
Expand All @@ -17,7 +17,7 @@ describe('newReservation Saga', () => {
};

const action = {
type: actionCreators.CREATE_RESERVATION,
type: actionTypes.CREATE_RESERVATION,
...input,
};

Expand Down Expand Up @@ -50,12 +50,12 @@ describe('newReservation Saga', () => {
],
])
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType: 'success',
message: 'Reservation created.',
})
.put({
type: onSuccessful(actionCreators.CREATE_RESERVATION),
type: onSuccessful(actionTypes.CREATE_RESERVATION),
response: {
data: mockResponse.data.createReservation.reservations,
},
Expand Down Expand Up @@ -83,12 +83,12 @@ describe('newReservation Saga', () => {
],
])
.put({
type: onFailure(actionCreators.CREATE_RESERVATION),
type: onFailure(actionTypes.CREATE_RESERVATION),
alertType,
message: expectedErrMessage,
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
Expand All @@ -113,7 +113,7 @@ describe('newReservation Saga', () => {
message: expectedErrMessage,
})
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
Expand Down
6 changes: 3 additions & 3 deletions frontend/specs/shared/base/baseApi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { waitFor } from '@testing-library/react';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';

import { actionCreators, createBaseApi } from '@/shared/base';
import { actionTypes, createBaseApi } from '@/shared/base';

describe('baseApi', () => {
const url = process.env.RESERVATION_API || '';
Expand Down Expand Up @@ -36,10 +36,10 @@ describe('baseApi', () => {
await baseApi.get('/test');
await waitFor(() => {
expect(mockStore.dispatch).toHaveBeenCalledWith({
type: actionCreators.API_REQUEST,
type: actionTypes.API_REQUEST,
});
expect(mockStore.dispatch).toHaveBeenCalledWith({
type: actionCreators.API_REQUEST_DONE,
type: actionTypes.API_REQUEST_DONE,
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions frontend/specs/shared/sagas/handleApiRequestError.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { takeLatest } from 'redux-saga/effects';

import { default as sharedSagas } from '../../../src/shared/sagas';
import { handleApiRequestError } from '../../../src/shared/sagas/handleApiRequestError';
import { actionCreators, } from '../../../src/shared/base';
import { actionTypes, } from '../../../src/shared/base';

describe('handleApiRequestError Saga', () => {
it('should dispatch SET_ALERT action with error message', () => {
Expand All @@ -14,7 +14,7 @@ describe('handleApiRequestError Saga', () => {

return expectSaga(handleApiRequestError, { error })
.put({
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
message: `Oops! Something went wrong. ${error.name}: ${error.message}`,
alertType: 'danger',
})
Expand All @@ -29,7 +29,7 @@ describe('handleApiRequestError Saga', () => {

return expectSaga(sharedSagas)
.provide([
[takeLatest(actionCreators.API_REQUEST_ERROR, handleApiRequestError), error],
[takeLatest(actionTypes.API_REQUEST_ERROR, handleApiRequestError), error],
])
.silentRun();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { takeLatest } from 'redux-saga/effects';

import { default as sharedSagas } from '../../../src/shared/sagas';
import { handleApiRequestUnauthorized } from '../../../src/shared/sagas/handleApiRequestUnauthorized';
import { actionCreators } from '../../../src/shared/base';
import { actionTypes } from '../../../src/shared/base';

describe('handleApiRequestUnauthorized Saga', () => {
it('should dispatch the LOGOUT action', () => {
return expectSaga(handleApiRequestUnauthorized)
.put({ type: actionCreators.LOGOUT })
.put({ type: actionTypes.LOGOUT })
.run();
});

it('should be invoked by latest API_REQUEST_UNAUTHORIZED dispatch', () => {
return expectSaga(sharedSagas)
.provide([
[takeLatest(actionCreators.API_REQUEST_UNAUTHORIZED, handleApiRequestUnauthorized)],
[takeLatest(actionTypes.API_REQUEST_UNAUTHORIZED, handleApiRequestUnauthorized)],
])
.silentRun();
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/specs/shared/sagas/logout.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { takeLatest } from 'redux-saga/effects';

import { default as sharedSagas } from '../../../src/shared/sagas';
import { logout } from '../../../src/shared/sagas/logout';
import { actionCreators, } from '../../../src/shared/base';
import { actionTypes, } from '../../../src/shared/base';

describe('logout Saga', () => {

it('should be invoked by latest LOGOUT dispatch', () => {
return expectSaga(sharedSagas)
.provide([
[takeLatest(actionCreators.LOGOUT, logout),],
[takeLatest(actionTypes.LOGOUT, logout),],
])
.silentRun();
});
Expand Down
16 changes: 8 additions & 8 deletions frontend/specs/shared/sharedReducer.spec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import reducer, { initialState } from '@/shared/sharedReducer'; // Replace 'yourReducer' with the actual file path
import { actionCreators } from '@/shared/base';
import { actionTypes } from '@/shared/base';

describe('sharedReducer tests', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('should handle API_REQUEST action', () => {
const action = { type: actionCreators.API_REQUEST };
const action = { type: actionTypes.API_REQUEST };
const newState = reducer(initialState, action);

expect(newState.requestInProgress).toBe(true);
expect(newState.count).toBe(1);
});

it('should handle API_REQUEST_DONE action', () => {
const action = { type: actionCreators.API_REQUEST_DONE };
const action = { type: actionTypes.API_REQUEST_DONE };

const newState = reducer(initialState, action);

Expand All @@ -25,7 +25,7 @@ describe('sharedReducer tests', () => {

it('should handle SET_ALERT action', () => {
const action = {
type: actionCreators.SET_ALERT,
type: actionTypes.SET_ALERT,
message: 'Sample alert message',
alertType: 'success',
};
Expand All @@ -38,7 +38,7 @@ describe('sharedReducer tests', () => {

it('should handle CLEAR_ALERT action', () => {
const action = {
type: actionCreators.CLEAR_ALERT,
type: actionTypes.CLEAR_ALERT,
};

const stateWithAlert = {
Expand All @@ -55,7 +55,7 @@ describe('sharedReducer tests', () => {

it('should handle OPEN_CONFIRMATION_MODAL action', () => {
const action = {
type: actionCreators.OPEN_CONFIRMATION_MODAL,
type: actionTypes.OPEN_CONFIRMATION_MODAL,
title: 'Confirmation Title',
message: 'Are you sure?',
text: 'Confirm',
Expand All @@ -82,7 +82,7 @@ describe('sharedReducer tests', () => {

it('should handle LOAD_COMPONENT action', () => {
const action = {
type: actionCreators.LOAD_COMPONENT,
type: actionTypes.LOAD_COMPONENT,
};

const newState = reducer(initialState, action);
Expand All @@ -93,7 +93,7 @@ describe('sharedReducer tests', () => {

it('should handle COMPONENT_NOT_FOUND action', () => {
const action = {
type: actionCreators.COMPONENT_NOT_FOUND,
type: actionTypes.COMPONENT_NOT_FOUND,
};

const newState = reducer(initialState, action);
Expand Down
Loading