NeoScan_Physician/app/modules/Profile/__tests__/profileSlice.test.ts

37 lines
1.1 KiB
TypeScript

/*
* File: profileSlice.test.ts
* Description: Test for profileSlice reducer
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/
import reducer, { fetchProfileSuccess, fetchProfileFailure, UserProfile } from '../redux/profileSlice';
const initialState = {
userProfile: null,
loading: false,
error: null,
};
describe('profileSlice', () => {
it('handles fetchProfileSuccess', () => {
const user: UserProfile = { id: '1', name: 'Dr. Smith', email: 'dr@hospital.com' };
const state = reducer(initialState, fetchProfileSuccess(user));
expect(state.userProfile).toEqual(user);
expect(state.loading).toBe(false);
expect(state.error).toBeNull();
});
it('handles fetchProfileFailure', () => {
const error = 'Failed to fetch';
const state = reducer(initialState, fetchProfileFailure(error));
expect(state.loading).toBe(false);
expect(state.error).toBe(error);
});
});
/*
* End of File: profileSlice.test.ts
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/