/*
 * File: authSlice.test.ts
 * Description: Test for authSlice reducer
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */

import reducer, { loginSuccess, loginFailure } from '../redux/authSlice';

const initialState = {
  user: null,
  loading: false,
  error: null,
  isAuthenticated: false,
};

describe('authSlice', () => {
  it('handles loginSuccess', () => {
    const user = { id: '1', name: 'Dr. Smith', email: 'dr@hospital.com' };
    const state = reducer(initialState, loginSuccess(user));
    expect(state.user).toEqual(user);
    expect(state.isAuthenticated).toBe(true);
    expect(state.loading).toBe(false);
    expect(state.error).toBeNull();
  });

  it('handles loginFailure', () => {
    const error = 'Invalid credentials';
    const state = reducer(initialState, loginFailure(error));
    expect(state.loading).toBe(false);
    expect(state.error).toBe(error);
    expect(state.isAuthenticated).toBe(false);
  });
});

/*
 * End of File: authSlice.test.ts
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */ 