It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
JSR Score
52%
Published
2 months ago (0.0.2)
import { describe, expect, it } from "bun:test"; import { Result } from "./index.ts"; describe("Result", () => { it("should be ok for non-error values", () => { let result: unknown = 1; expect(Result.isOk(result)).toBe(true); result = "test"; expect(Result.isOk(result)).toBe(true); result = true; expect(Result.isOk(result)).toBe(true); result = new Date(); expect(Result.isOk(result)).toBe(true); result = new Error("test"); expect(Result.isOk(result)).toBe(false); }); it("should be Err for error values", () => { let result: unknown = new Error("test"); expect(Result.isErr(result)).toBe(true); expect(Result.isOk(result)).toBe(false); result = "test"; expect(Result.isErr(result)).toBe(false); expect(Result.isOk(result)).toBe(true); result = 1; expect(Result.isErr(result)).toBe(false); result = true; expect(Result.isErr(result)).toBe(false); }); });