Skip to content

Commit 606461b

Browse files
authored
test: fix some typing issues across tests (#79)
1 parent ae5d546 commit 606461b

File tree

2 files changed

+29
-34
lines changed

2 files changed

+29
-34
lines changed

spec/tests/Iterate.spec.tsx

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('`Iterate` component', () => {
7676
gray('When updated with non-iterable values consecutively will render correctly'),
7777
async () => {
7878
let timesRerendered = 0;
79-
let lastRenderFnInput: undefined | IterationResult<string>;
79+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
8080

8181
const rendered = render(<></>);
8282

@@ -109,7 +109,7 @@ describe('`Iterate` component', () => {
109109
gray('When given a non-iterable value starting with some initial value will render correctly'),
110110
async () => {
111111
let timesRerendered = 0;
112-
let lastRenderFnInput: undefined | IterationResult<string>;
112+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
113113

114114
const rendered = render(
115115
<Iterate initialValue="_" value="a">
@@ -137,7 +137,7 @@ describe('`Iterate` component', () => {
137137
it(gray('When given an iterable that yields a value will render correctly'), async () => {
138138
const channel = new IteratorChannelTestHelper<string>();
139139
let timesRerendered = 0;
140-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
140+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
141141

142142
const rendered = render(
143143
<Iterate value={channel}>
@@ -181,7 +181,7 @@ describe('`Iterate` component', () => {
181181
async () => {
182182
const channel = new IteratorChannelTestHelper<string>();
183183
let timesRerendered = 0;
184-
let lastRenderFnInput: undefined | IterationResult<string>;
184+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
185185

186186
const rendered = render(
187187
<Iterate initialValue="_" value={channel}>
@@ -222,7 +222,7 @@ describe('`Iterate` component', () => {
222222
it(gray('When given an iterable that yields multiple values will render correctly'), async () => {
223223
const channel = new IteratorChannelTestHelper<string>();
224224
let timesRerendered = 0;
225-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
225+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
226226

227227
const rendered = render(
228228
<Iterate value={channel}>
@@ -266,7 +266,7 @@ describe('`Iterate` component', () => {
266266
async () => {
267267
const emptyIter = (async function* () {})();
268268
let timesRerendered = 0;
269-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
269+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
270270

271271
const rendered = render(
272272
<Iterate value={emptyIter}>
@@ -300,7 +300,7 @@ describe('`Iterate` component', () => {
300300
async () => {
301301
const emptyIter = (async function* () {})();
302302
let timesRerendered = 0;
303-
let lastRenderFnInput: undefined | IterationResult<string>;
303+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
304304

305305
const rendered = render(
306306
<Iterate initialValue="_" value={emptyIter}>
@@ -332,7 +332,7 @@ describe('`Iterate` component', () => {
332332
async () => {
333333
const channel = new IteratorChannelTestHelper<string>();
334334
let timesRerendered = 0;
335-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
335+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
336336

337337
const rendered = render(
338338
<Iterate value={channel}>
@@ -379,7 +379,7 @@ describe('`Iterate` component', () => {
379379
throw simulatedError;
380380
})();
381381
let timesRerendered = 0;
382-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
382+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
383383

384384
const rendered = render(
385385
<Iterate value={erroringIter}>
@@ -415,7 +415,7 @@ describe('`Iterate` component', () => {
415415
throw simulatedError;
416416
})();
417417
let timesRerendered = 0;
418-
let lastRenderFnInput: undefined | IterationResult<string>;
418+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
419419

420420
const rendered = render(
421421
<Iterate initialValue="_" value={erroringIter}>
@@ -447,7 +447,7 @@ describe('`Iterate` component', () => {
447447
async () => {
448448
const channel = new IteratorChannelTestHelper<string>();
449449
let timesRerendered = 0;
450-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
450+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
451451

452452
const simulatedErr = new Error('...');
453453

@@ -494,7 +494,7 @@ describe('`Iterate` component', () => {
494494
"When consecutively updated with new iterables will close the previous one's iterator every time and render accordingly"
495495
),
496496
async () => {
497-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
497+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
498498

499499
const [channel1, channel2] = [
500500
new IteratorChannelTestHelper<string>(),
@@ -692,7 +692,7 @@ describe('`Iterate` component', () => {
692692
);
693693

694694
it(gray('When unmounted will close the last active iterator it held'), async () => {
695-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
695+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
696696

697697
const channel = new IteratorChannelTestHelper<string>();
698698

@@ -745,20 +745,20 @@ describe('`Iterate` component', () => {
745745
async () => {
746746
const iter = asyncIterOf('a', 'b', 'c');
747747
let timesRerendered = 0;
748-
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
748+
let lastRenderFnInput: undefined | IterationResult<AsyncIterable<string>>;
749749

750-
const rendered = render(
751-
<Iterate value={iter}>
752-
{next => {
753-
timesRerendered++;
754-
lastRenderFnInput = next;
755-
return <div id="test-created-elem">Render count: {timesRerendered}</div>;
756-
}}
757-
</Iterate>
750+
const rendered = await act(() =>
751+
render(
752+
<Iterate value={iter}>
753+
{next => {
754+
timesRerendered++;
755+
lastRenderFnInput = next;
756+
return <div id="test-created-elem">Render count: {timesRerendered}</div>;
757+
}}
758+
</Iterate>
759+
)
758760
);
759761

760-
await act(() => {});
761-
762762
expect(lastRenderFnInput).toStrictEqual({
763763
value: 'c',
764764
pendingFirst: false,
@@ -778,9 +778,7 @@ describe('`Iterate` component', () => {
778778
),
779779
async () => {
780780
const channel = new IteratorChannelTestHelper<string>();
781-
const renderFn = vi.fn() as Mock<
782-
(next: IterationResult<AsyncIterable<string | undefined>>) => any
783-
>;
781+
const renderFn = vi.fn() as Mock<(next: IterationResult<AsyncIterable<string>>) => any>;
784782

785783
const rendered = render(
786784
<Iterate value={channel}>
@@ -809,10 +807,8 @@ describe('`Iterate` component', () => {
809807
"When given iterable's first yield is identical to the previous value, the component does re-render"
810808
),
811809
async () => {
812-
const renderFn = vi.fn() as Mock<
813-
(next: IterationResult<AsyncIterable<string | undefined>>) => any
814-
>;
815-
const channel1 = new IteratorChannelTestHelper<string>();
810+
const renderFn = vi.fn() as Mock<(next: IterationResult<AsyncIterable<string>>) => any>;
811+
const channel = new IteratorChannelTestHelper<string>();
816812

817813
const Component = (props: { value: AsyncIterable<string> }) => {
818814
return (
@@ -824,9 +820,9 @@ describe('`Iterate` component', () => {
824820
);
825821
};
826822

827-
const rendered = await act(() => render(<Component value={channel1} />));
823+
const rendered = await act(() => render(<Component value={channel} />));
828824

829-
await act(() => channel1.put('a'));
825+
await act(() => channel.put('a'));
830826

831827
const channel2 = new IteratorChannelTestHelper<string>();
832828
await act(() => rendered.rerender(<Component value={channel2} />));

spec/tests/useAsyncIterState.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ describe('`useAsyncIterState` hook', () => {
215215
for (let i = 0; i < 3; ++i) {
216216
setValue(valueUpdateInput.mockImplementation(_prev => i));
217217
currentValues.push(values.value.current);
218-
// await undefined;
219218
}
220219

221220
expect(valueUpdateInput.mock.calls).toStrictEqual([[undefined], [0], [1]]);

0 commit comments

Comments
 (0)