Skip to content

Commit

Permalink
feat: remove act function in hook testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Flower-F committed May 17, 2024
1 parent fe3c685 commit 71388a1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/hook.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { act, renderHook } from '@testing-library/react';
import { renderHook } from '@testing-library/react';
import { useCounter } from 'ahooks';
import { describe, expect, it } from 'vitest';

describe('useCounter', () => {
it('increment & decrement', () => {
const { result } = renderHook(() => useCounter());
const { result, rerender } = renderHook(() => useCounter());
expect(result.current[0]).toMatchInlineSnapshot('0');
act(() => result.current[1].inc(1));
result.current[1].inc(1);
rerender();
expect(result.current[0]).toMatchInlineSnapshot('1');
act(() => result.current[1].dec(1));
result.current[1].dec(1);
rerender();
expect(result.current[0]).toMatchInlineSnapshot('0');
});
});

0 comments on commit 71388a1

Please sign in to comment.