Files
ontime/apps/client/src/common/utils/__tests__/queryUtils.test.ts
T
Claude f7b58f5ebd refactor(views): use react-query's isLoadingError instead of reimplementing it
deriveQueryStatus previously inferred "never received data" by checking
data !== undefined itself. TanStack Query already computes and exposes
this exact distinction as isLoadingError (isError && no data) vs
isRefetchError (isError && data present) on every useQuery result, so
consume that directly instead of duplicating the logic.
2026-08-01 18:59:39 +00:00

15 lines
544 B
TypeScript

import { deriveQueryStatus } from '../queryUtils';
test('keeps pending and success statuses unchanged', () => {
expect(deriveQueryStatus('pending', false)).toBe('pending');
expect(deriveQueryStatus('success', false)).toBe('success');
});
test('keeps error status on a genuine loading error (no data ever received)', () => {
expect(deriveQueryStatus('error', true)).toBe('error');
});
test('downgrades error to success on a refetch error (data still available)', () => {
expect(deriveQueryStatus('error', false)).toBe('success');
});