import { describe, expect, test } from "vitest"; import { ApiError } from "../api-error"; import { createQueryClient, shouldRetryQuery } from "../query-client"; describe("TanStack Query defaults", () => { test("does not retry unauthenticated query errors", () => { // Given const error = new ApiError({ status: 401, message: "인증 정보가 없습니다.", errorProperty: null, }); // When const shouldRetry = shouldRetryQuery(0, error); // Then expect(shouldRetry).toBe(false); }); test("does not retry access-denied query errors", () => { // Given const error = new ApiError({ status: 403, message: "접근 권한이 없습니다.", errorProperty: null, }); // When const shouldRetry = shouldRetryQuery(0, error); // Then expect(shouldRetry).toBe(false); }); test("limits retries for other query errors", () => { // Given const error = new Error("network failure"); // When const shouldRetry = shouldRetryQuery(2, error); // Then expect(shouldRetry).toBe(false); }); test("disables mutation retries", () => { // Given const queryClient = createQueryClient(); // When const retry = queryClient.getDefaultOptions().mutations?.retry; // Then expect(retry).toBe(false); }); });