Skip to content

Commit b08bd44

Browse files
committed
🦄 refactor: Simplify type definitions
1 parent ec49b74 commit b08bd44

4 files changed

Lines changed: 177 additions & 468 deletions

File tree

src/README.example.spec.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ test("Handling return values", () => {
681681
],
682682
]
683683
`);
684-
logSpy.mockRestore();
685684
}
686685
});
687686

@@ -779,23 +778,29 @@ test("Handling multiple effects in one handler", () => {
779778
const logs: unknown[][] = [];
780779
expect(
781780
range2(1, 0)
782-
.resume("println", (...args) => logs.push(args))
781+
.resume("println", (...args) => {
782+
logs.push(args);
783+
})
783784
.runSync(),
784785
).toEqual(err({ error: "range", message: "Start must be less than stop" }));
785786
expect(logs).toEqual([]);
786787
logs.length = 0;
787788

788789
expect(
789790
range2(1.5, 5)
790-
.resume("println", (...args) => logs.push(args))
791+
.resume("println", (...args) => {
792+
logs.push(args);
793+
})
791794
.runSync(),
792795
).toEqual(err({ error: "type", message: "Start and stop must be integers" }));
793796
expect(logs).toEqual([]);
794797
logs.length = 0;
795798

796799
expect(
797800
range2(1, 5)
798-
.resume("println", (...args) => logs.push(args))
801+
.resume("println", (...args) => {
802+
logs.push(args);
803+
})
799804
.runSync(),
800805
).toEqual(ok([1, 2, 3, 4]));
801806
expect(logs).toEqual([["Generating range from 1 to 5"]]);
@@ -805,23 +810,29 @@ test("Handling multiple effects in one handler", () => {
805810

806811
expect(
807812
range3(1, 0)
808-
.resume("println", (...args) => logs.push(args))
813+
.resume("println", (...args) => {
814+
logs.push(args);
815+
})
809816
.runSync(),
810817
).toEqual(err({ error: "range", message: "Start must be less than stop" }));
811818
expect(logs).toEqual([]);
812819
logs.length = 0;
813820

814821
expect(
815822
range3(1.5, 5)
816-
.resume("println", (...args) => logs.push(args))
823+
.resume("println", (...args) => {
824+
logs.push(args);
825+
})
817826
.runSync(),
818827
).toEqual(err({ error: "type", message: "Start and stop must be integers" }));
819828
expect(logs).toEqual([]);
820829
logs.length = 0;
821830

822831
expect(
823832
range3(1, 5)
824-
.resume("println", (...args) => logs.push(args))
833+
.resume("println", (...args) => {
834+
logs.push(args);
835+
})
825836
.runSync(),
826837
).toEqual(ok([1, 2, 3, 4]));
827838
expect(logs).toEqual([["Generating range from 1 to 5"]]);
@@ -834,23 +845,29 @@ test("Handling multiple effects in one handler", () => {
834845

835846
expect(
836847
range4(1, 0)
837-
.resume("println", (...args) => logs.push(args))
848+
.resume("println", (...args) => {
849+
logs.push(args);
850+
})
838851
.runSync(),
839852
).toEqual(err({ error: "range", message: "Start must be less than stop" }));
840853
expect(logs).toEqual([]);
841854
logs.length = 0;
842855

843856
expect(
844857
range4(1.5, 5)
845-
.resume("println", (...args) => logs.push(args))
858+
.resume("println", (...args) => {
859+
logs.push(args);
860+
})
846861
.runSync(),
847862
).toEqual(err({ error: "type", message: "Start and stop must be integers" }));
848863
expect(logs).toEqual([]);
849864
logs.length = 0;
850865

851866
expect(
852867
range4(1, 5)
853-
.resume("println", (...args) => logs.push(args))
868+
.resume("println", (...args) => {
869+
logs.push(args);
870+
})
854871
.runSync(),
855872
).toEqual(ok([1, 2, 3, 4]));
856873
expect(logs).toEqual([["Generating range from 1 to 5"]]);

src/backend-app.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ test("app", () => {
128128
}
129129
})
130130
.provideBy("currentUser", () => currentUser)
131-
.resume("setCurrentUser", (user) => (currentUser = user))
131+
.resume("setCurrentUser", (user) => {
132+
currentUser = user;
133+
})
132134
.catch("authentication", console.error)
133135
.catch("unauthorized", console.error)
134136
.catch("userNotFound", console.error)

src/effected.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ describe("Effected#tap", () => {
628628
Effected.of(42)
629629
.tap((value) => {
630630
logs.push(["tap", value]);
631-
return value + 1;
631+
return (value + 1) as unknown as void;
632632
})
633633
.runSync(),
634634
).toBe(42);
@@ -643,7 +643,9 @@ describe("Effected#tap", () => {
643643
yield* log("tap", value);
644644
return (value + 1) as unknown as void;
645645
})
646-
.resume("log", (...args) => Array.prototype.push.apply(logs, args))
646+
.resume("log", (...args) => {
647+
Array.prototype.push.apply(logs, args);
648+
})
647649
.runSync(),
648650
).toBe(42);
649651
expect(logs).toEqual(["tap", 42]);
@@ -657,7 +659,9 @@ describe("Effected#tap", () => {
657659
return (value + 1) as unknown as void;
658660
}),
659661
)
660-
.resume("log", (...args) => Array.prototype.push.apply(logs, args))
662+
.resume("log", (...args) => {
663+
Array.prototype.push.apply(logs, args);
664+
})
661665
.runSync(),
662666
).toBe(42);
663667
expect(logs).toEqual(["tap", 42]);

0 commit comments

Comments
 (0)