import { describe, expect, it } from 'vitest' import { getSafetyTrainingRouteConversationId, shouldShowSafetyTrainingRouteLoading } from './safetyTrainingRouteLoading' describe('safetyTrainingRouteLoading', () => { it('uses a positive route id as the conversation to load', () => { expect(getSafetyTrainingRouteConversationId({ id: '9876' })).toBe(9876) expect(getSafetyTrainingRouteConversationId({ id: 42 })).toBe(42) }) it('ignores invalid route ids', () => { expect(getSafetyTrainingRouteConversationId({ id: 'abc' })).toBeNull() expect(getSafetyTrainingRouteConversationId({ id: '0' })).toBeNull() expect(getSafetyTrainingRouteConversationId({})).toBeNull() }) it('only shows the route loading state while a valid route conversation is loading', () => { expect(shouldShowSafetyTrainingRouteLoading({ query: { id: '9876' }, isLoading: true })).toBe(true) expect(shouldShowSafetyTrainingRouteLoading({ query: { id: '9876' }, isLoading: false })).toBe(false) expect(shouldShowSafetyTrainingRouteLoading({ query: { id: 'abc' }, isLoading: true })).toBe(false) }) })