Skip to content

Commit 4ee5e89

Browse files
authored
test: general test edits (#29)
* edits across test files
1 parent d813fa0 commit 4ee5e89

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

spec/tests/Iterate.spec.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { it, describe, expect, afterEach, vi } from 'vitest';
22
import { gray } from 'colorette';
33
import { render, cleanup as cleanupMountedReactTrees, act } from '@testing-library/react';
44
import { Iterate, It, type IterationResult } from '../../src/index.js';
5+
import { asyncIterOf } from '../utils/asyncIterOf.js';
56
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';
67

78
afterEach(() => {
@@ -634,12 +635,10 @@ describe('`Iterate` component', () => {
634635

635636
it(
636637
gray(
637-
'When given a rapid yielding iterable, consecutive values are batched into a single render that takes only the last value'
638+
'When given a rapid-yielding iterable, consecutive values are batched into a single render that takes only the last value'
638639
),
639640
async () => {
640-
const iter = (async function* () {
641-
yield* ['a', 'b', 'c'];
642-
})();
641+
const iter = asyncIterOf('a', 'b', 'c');
643642
let timesRerendered = 0;
644643
let lastRenderFnInput: undefined | IterationResult<string | undefined>;
645644

@@ -669,9 +668,7 @@ describe('`Iterate` component', () => {
669668
);
670669

671670
it(
672-
gray(
673-
'When given iterable yields consecutive identical values the hook will not consequently re-render'
674-
),
671+
gray('When given iterable yields consecutive identical values the hook will not re-render'),
675672
async () => {
676673
let timesRerendered = 0;
677674
let lastRenderFnInput: undefined | IterationResult<string | undefined>;

spec/tests/iterateFormatted.spec.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { gray } from 'colorette';
33
import { render, cleanup as cleanupMountedReactTrees, act } from '@testing-library/react';
44
import { iterateFormatted, Iterate } from '../../src/index.js';
55
import { pipe } from '../utils/pipe.js';
6+
import { asyncIterOf } from '../utils/asyncIterOf.js';
67
import { asyncIterToArray } from '../utils/asyncIterToArray.js';
78
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';
89

@@ -28,9 +29,7 @@ describe('`iterateFormatted` function', () => {
2829
),
2930
async () => {
3031
const multiFormattedIter = pipe(
31-
(async function* () {
32-
yield* ['a', 'b', 'c'];
33-
})(),
32+
asyncIterOf('a', 'b', 'c'),
3433
$ => iterateFormatted($, (value, i) => `${value} formatted once (idx: ${i})`),
3534
$ => iterateFormatted($, (value, i) => `${value} and formatted twice (idx: ${i})`)
3635
);

spec/tests/useAsyncIter.spec.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { it, describe, expect, afterEach, vi } from 'vitest';
22
import { gray } from 'colorette';
33
import { cleanup as cleanupMountedReactTrees, act, renderHook } from '@testing-library/react';
44
import { useAsyncIter } from '../../src/index.js';
5+
import { asyncIterOf } from '../utils/asyncIterOf.js';
56
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';
67

78
afterEach(() => {
@@ -447,13 +448,11 @@ describe('`useAsyncIter` hook', () => {
447448

448449
it(
449450
gray(
450-
'When given a rapid yielding iterable, consecutive values are batched into a single render that takes only the last value'
451+
'When given a rapid-yielding iterable, consecutive values are batched into a single render that takes only the last value'
451452
),
452453
async () => {
453454
let timesRerendered = 0;
454-
const iter = (async function* () {
455-
yield* ['a', 'b', 'c'];
456-
})();
455+
const iter = asyncIterOf('a', 'b', 'c');
457456

458457
const renderedHook = renderHook(() => {
459458
timesRerendered++;
@@ -473,9 +472,7 @@ describe('`useAsyncIter` hook', () => {
473472
);
474473

475474
it(
476-
gray(
477-
'When given iterable yields consecutive identical values the hook will not consequently re-render'
478-
),
475+
gray('When given iterable yields consecutive identical values the hook will not re-render'),
479476
async () => {
480477
let timesRerendered = 0;
481478
const channel = new IteratorChannelTestHelper<string>();

0 commit comments

Comments
 (0)