Skip to content

Commit ef6eae2

Browse files
committed
[hygiene] Shrink acts
1 parent 20c9ac0 commit ef6eae2

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

test/unit/core/documentation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const prepareTestResultsFromBlock = (block: string, prefix: string): void => {
163163
?.replace(/\/\/ -> (.*?)$/gm, '_expected.push($1);\n')
164164
?.replace(
165165
/\/\/ \.\.\. \/\/ !act$/gm,
166-
'await act(async () => {await pause();});\n',
166+
'await act(async () => await pause());\n',
167167
)
168168
?.replace(/\/\/ \.\.\.$/gm, 'await pause();\n')
169169
?.replace(/^(.*?) \/\/ !act$/gm, 'act(() => {$1});')

test/unit/core/ui-react/hooks.test.tsx

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -456,23 +456,17 @@ describe('Create Hooks', () => {
456456
};
457457

458458
const {container, rerender, unmount} = render(<Test id={1} />);
459-
await act(async () => {
460-
await pause();
461-
});
459+
await act(async () => await pause());
462460
expect(container.textContent).toEqual(
463461
JSON.stringify([1, {loads: 0, saves: 0}, null]),
464462
);
465-
await act(async () => {
466-
await _persister?.load([{t1: {r1: {c1: 1}}}, {}]);
467-
});
463+
await act(async () => await _persister?.load([{t1: {r1: {c1: 1}}}, {}]));
468464
expect(container.textContent).toEqual(
469465
JSON.stringify([1, {loads: 1, saves: 0}, 1]),
470466
);
471467

472468
rerender(<Test id={2} />);
473-
await act(async () => {
474-
await pause();
475-
});
469+
await act(async () => await pause());
476470
expect(container.textContent).toEqual(
477471
JSON.stringify([2, {loads: 0, saves: 0}, 1]),
478472
);
@@ -514,17 +508,13 @@ describe('Create Hooks', () => {
514508
expect(container.textContent).toEqual(JSON.stringify([0, null]));
515509

516510
rerender(<Test id={1} />);
517-
await act(async () => {
518-
await pause();
519-
});
511+
await act(async () => await pause());
520512
expect(container.textContent).toEqual(
521513
JSON.stringify([1, {loads: 1, saves: 0}]),
522514
);
523515

524516
rerender(<Test id={2} />);
525-
await act(async () => {
526-
await pause();
527-
});
517+
await act(async () => await pause());
528518
expect(container.textContent).toEqual(
529519
JSON.stringify([2, {loads: 1, saves: 0}]),
530520
);
@@ -569,17 +559,13 @@ describe('Create Hooks', () => {
569559
};
570560

571561
const {container, rerender, unmount} = render(<Test id={1} />);
572-
await act(async () => {
573-
await pause();
574-
});
562+
await act(async () => await pause());
575563
expect(container.textContent).toEqual(
576564
JSON.stringify([1, {loads: 1, saves: 0}]),
577565
);
578566

579567
rerender(<Test id={2} />);
580-
await act(async () => {
581-
await pause();
582-
});
568+
await act(async () => await pause());
583569
expect(container.textContent).toEqual(
584570
JSON.stringify([2, {loads: 1, saves: 0}]),
585571
);

0 commit comments

Comments
 (0)