diff --git a/jam-ui/src/store/features/__tests__/sessionChatSlice.test.js b/jam-ui/src/store/features/__tests__/sessionChatSlice.test.js new file mode 100644 index 000000000..45116551e --- /dev/null +++ b/jam-ui/src/store/features/__tests__/sessionChatSlice.test.js @@ -0,0 +1,81 @@ +import sessionChatReducer from '../sessionChatSlice'; + +describe('sessionChatSlice initial state', () => { + test('has empty messagesByChannel object', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.messagesByChannel).toEqual({}); + }); + + test('has null activeChannel', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.activeChannel).toBeNull(); + }); + + test('has null channelType', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.channelType).toBeNull(); + }); + + test('has empty unreadCounts object', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.unreadCounts).toEqual({}); + }); + + test('has empty lastReadAt object', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.lastReadAt).toEqual({}); + }); + + test('has empty fetchStatus object', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.fetchStatus).toEqual({}); + }); + + test('has empty fetchError object', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.fetchError).toEqual({}); + }); + + test('has idle sendStatus', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.sendStatus).toBe('idle'); + }); + + test('has null sendError', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.sendError).toBeNull(); + }); + + test('has empty nextCursors object', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.nextCursors).toEqual({}); + }); + + test('has isWindowOpen set to false', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.isWindowOpen).toBe(false); + }); + + test('has null windowPosition', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state.windowPosition).toBeNull(); + }); + + test('complete initial state structure matches design', () => { + const state = sessionChatReducer(undefined, { type: 'unknown' }); + expect(state).toEqual({ + messagesByChannel: {}, + activeChannel: null, + channelType: null, + unreadCounts: {}, + lastReadAt: {}, + fetchStatus: {}, + fetchError: {}, + sendStatus: 'idle', + sendError: null, + nextCursors: {}, + isWindowOpen: false, + windowPosition: null + }); + }); +});