Files
gochat/frontend/app/javascript/dashboard/helper/specs/conversationNavigation.spec.js
T

22 lines
704 B
JavaScript

import { getAdjacentConversationId } from '../conversationNavigation';
describe('getAdjacentConversationId', () => {
const conversationIds = [15, 19, 25];
it('selects the immediate next conversation', () => {
expect(getAdjacentConversationId(conversationIds, 15)).toBe(19);
});
it('selects the previous conversation for the last item', () => {
expect(getAdjacentConversationId(conversationIds, 25)).toBe(19);
});
it('returns null for a single-item list', () => {
expect(getAdjacentConversationId([15], 15)).toBeNull();
});
it('returns null when the current conversation is absent', () => {
expect(getAdjacentConversationId(conversationIds, 99)).toBeNull();
});
});