Skip to content

Commit

Permalink
Test API utils
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Apr 17, 2024
1 parent b2e70e8 commit c05fea0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib/utils/api.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test, expect } from "vitest";
import { isErrorCode, isRedirectCode } from "./api";

test("isErrorCode", () => {
expect(isErrorCode(200)).toBe(false);
expect(isErrorCode(204)).toBe(false);
expect(isErrorCode(301)).toBe(false);
expect(isErrorCode(307)).toBe(false);
expect(isErrorCode(400)).toBe(true);
expect(isErrorCode(404)).toBe(true);
expect(isErrorCode(500)).toBe(true);
});

test("isRedirectCode", () => {
expect(isRedirectCode(200)).toBe(false);
expect(isRedirectCode(204)).toBe(false);
expect(isRedirectCode(301)).toBe(true);
expect(isRedirectCode(307)).toBe(true);
expect(isRedirectCode(400)).toBe(false);
expect(isRedirectCode(404)).toBe(false);
expect(isRedirectCode(500)).toBe(false);
});

0 comments on commit c05fea0

Please sign in to comment.