Skip to content

Commit

Permalink
add default value type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtatranta committed Nov 26, 2024
1 parent 9cedb47 commit cf5751e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Maybe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ describe("Maybe", () => {
expect(result).toEqual("a");
});

it("should return the default value type when the mapping returns falsy", () => {
const result: "b" = Maybe.of("a" as const)
.map(() => null)
.getValue("b");
expect(result).toEqual("b");
});

it("should return the default value type when the value is null", () => {
const result: "b" = Maybe.of(null).getValue("b");
expect(result).toEqual("b");
});

it("should return original when default parameter is NOT passed to getValue()", () => {
const a = "a" as const;

Expand Down

0 comments on commit cf5751e

Please sign in to comment.