safetyTrainingRouteLoading.test.js 1.1 KB

12345678910111213141516171819202122232425
  1. import { describe, expect, it } from 'vitest'
  2. import {
  3. getSafetyTrainingRouteConversationId,
  4. shouldShowSafetyTrainingRouteLoading
  5. } from './safetyTrainingRouteLoading'
  6. describe('safetyTrainingRouteLoading', () => {
  7. it('uses a positive route id as the conversation to load', () => {
  8. expect(getSafetyTrainingRouteConversationId({ id: '9876' })).toBe(9876)
  9. expect(getSafetyTrainingRouteConversationId({ id: 42 })).toBe(42)
  10. })
  11. it('ignores invalid route ids', () => {
  12. expect(getSafetyTrainingRouteConversationId({ id: 'abc' })).toBeNull()
  13. expect(getSafetyTrainingRouteConversationId({ id: '0' })).toBeNull()
  14. expect(getSafetyTrainingRouteConversationId({})).toBeNull()
  15. })
  16. it('only shows the route loading state while a valid route conversation is loading', () => {
  17. expect(shouldShowSafetyTrainingRouteLoading({ query: { id: '9876' }, isLoading: true })).toBe(true)
  18. expect(shouldShowSafetyTrainingRouteLoading({ query: { id: '9876' }, isLoading: false })).toBe(false)
  19. expect(shouldShowSafetyTrainingRouteLoading({ query: { id: 'abc' }, isLoading: true })).toBe(false)
  20. })
  21. })