From 88a00dbf9ed3d38d1023a09b9ac8d265fa4994f0 Mon Sep 17 00:00:00 2001
From: MadCcc <1075746765@qq.com>
Date: Wed, 24 May 2023 22:03:26 +0800
Subject: [PATCH] test: update test case (#42582)
* chore: update snapshot
* chore: update test case
* chore: rm watermark image test
---
components/tree/__tests__/directory.test.tsx | 20 ++++++++++----------
components/watermark/__tests__/image.test.ts | 5 -----
package.json | 2 +-
3 files changed, 11 insertions(+), 16 deletions(-)
delete mode 100644 components/watermark/__tests__/image.test.ts
diff --git a/components/tree/__tests__/directory.test.tsx b/components/tree/__tests__/directory.test.tsx
index 31f3119d3a..c2101c72ee 100644
--- a/components/tree/__tests__/directory.test.tsx
+++ b/components/tree/__tests__/directory.test.tsx
@@ -1,12 +1,12 @@
-import React from 'react';
import debounce from 'lodash/debounce';
-import type { Key } from 'react';
import type RcTree from 'rc-tree';
+import type { Key } from 'react';
+import React from 'react';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
-import { act, fireEvent, render } from '../../../tests/utils';
-import Tree from '../index';
+import { act, fireEvent, render, waitFakeTimer } from '../../../tests/utils';
import type { TreeProps } from '../index';
+import Tree from '../index';
const { DirectoryTree, TreeNode } = Tree;
@@ -100,18 +100,18 @@ describe('Directory Tree', () => {
);
};
- it('click', () => {
+ it('click', async () => {
const { container, asFragment } = render();
fireEvent.click(container.querySelector('.ant-tree-node-content-wrapper')!);
- jest.runAllTimers();
+ await waitFakeTimer();
expect(asFragment().firstChild).toMatchSnapshot();
});
- it('doubleClick', () => {
+ it('doubleClick', async () => {
const { container, asFragment } = render();
fireEvent.doubleClick(container.querySelector('.ant-tree-node-content-wrapper')!);
- jest.runAllTimers();
+ await waitFakeTimer();
expect(asFragment().firstChild).toMatchSnapshot();
});
});
@@ -151,10 +151,10 @@ describe('Directory Tree', () => {
expect(asFragment().firstChild).toMatchSnapshot();
});
- it('expandedKeys update', () => {
+ it('expandedKeys update', async () => {
const { rerender, asFragment } = render(createTree());
rerender(createTree({ expandedKeys: ['0-1'] }));
- jest.runAllTimers();
+ await waitFakeTimer();
expect(asFragment().firstChild).toMatchSnapshot();
});
diff --git a/components/watermark/__tests__/image.test.ts b/components/watermark/__tests__/image.test.ts
deleted file mode 100644
index 04fae6f308..0000000000
--- a/components/watermark/__tests__/image.test.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { imageDemoTest } from '../../../tests/shared/imageTest';
-
-describe('Watermark image', () => {
- imageDemoTest('watermark');
-});
diff --git a/package.json b/package.json
index 6fde10e450..c79173afda 100644
--- a/package.json
+++ b/package.json
@@ -149,7 +149,7 @@
"rc-tabs": "~12.6.0",
"rc-textarea": "~1.2.2",
"rc-tooltip": "~6.0.0",
- "rc-tree": "~5.7.0",
+ "rc-tree": "~5.7.4",
"rc-tree-select": "~5.9.0",
"rc-upload": "~4.3.0",
"rc-util": "^5.27.0",