+describe("maybe", () => {
+ it("[[Call]] calls if not nullish", () => {
+ const wrapper = spy(() => "success");
+ assertStrictEquals(maybe(0, wrapper), "success");
+ assertSpyCalls(wrapper, 1);
+ assertSpyCall(wrapper, 0, {
+ args: [0],
+ self: undefined,
+ returned: "success",
+ });
+ });
+
+ it("[[Call]] does not call if nullish", () => {
+ const wrapper = spy(() => "success");
+ assertStrictEquals(maybe(null, wrapper), null);
+ assertStrictEquals(maybe(undefined, wrapper), undefined);
+ assertSpyCalls(wrapper, 0);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new maybe(true, ($) => $));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(maybe.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(maybe.name, "maybe");
+ });
+ });
+});
+