Skip to content

Commit 1d2884b

Browse files
authored
test: update tag test case (#788)
1 parent b4a37bc commit 1d2884b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

site/test-coverage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
empty: { statements: '100%', branches: '100%', functions: '100%', lines: '100%' },
2222
fab: { statements: '5.4%', branches: '0%', functions: '0%', lines: '5.4%' },
2323
footer: { statements: '100%', branches: '100%', functions: '100%', lines: '100%' },
24-
form: { statements: '2.8%', branches: '0%', functions: '0%', lines: '2.96%' },
24+
form: { statements: '2.79%', branches: '0%', functions: '0%', lines: '2.95%' },
2525
grid: { statements: '100%', branches: '100%', functions: '100%', lines: '100%' },
2626
guide: { statements: '3.46%', branches: '0%', functions: '0%', lines: '3.77%' },
2727
hooks: { statements: '70.7%', branches: '45.88%', functions: '73.68%', lines: '70.66%' },
@@ -60,7 +60,7 @@ module.exports = {
6060
tabBar: { statements: '100%', branches: '93.18%', functions: '100%', lines: '100%' },
6161
table: { statements: '100%', branches: '90%', functions: '100%', lines: '100%' },
6262
tabs: { statements: '43.22%', branches: '18.75%', functions: '56%', lines: '45.07%' },
63-
tag: { statements: '100%', branches: '96.87%', functions: '100%', lines: '100%' },
63+
tag: { statements: '100%', branches: '100%', functions: '100%', lines: '100%' },
6464
textarea: { statements: '98.64%', branches: '95%', functions: '93.33%', lines: '100%' },
6565
toast: { statements: '98.73%', branches: '100%', functions: '94.11%', lines: '98.66%' },
6666
treeSelect: { statements: '5.4%', branches: '0%', functions: '0%', lines: '5.88%' },
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, vi } from '@test/utils';
1+
import { describe, vi, it, expect } from '@test/utils';
22
import { fireEvent, render } from '@testing-library/react';
33
import React from 'react';
44
import { AppIcon } from 'tdesign-icons-react';
@@ -158,9 +158,12 @@ describe('TagCheck', () => {
158158
});
159159

160160
it(': checked', () => {
161-
const { container } = render(<TagCheck defaultChecked content={['已选中态', '未选中态']}></TagCheck>);
161+
const { container, rerender } = render(<TagCheck defaultChecked content={['已选中态', '未选中态']}></TagCheck>);
162162
const $tagItem = container.querySelector(baseClass) as HTMLElement;
163163
expect($tagItem.classList.contains(`${baseClass}--checked`));
164+
165+
rerender(<TagCheck checked={false} content={['已选中态', '未选中态']}></TagCheck>);
166+
expect(container.querySelector(`${baseClass}__text`).innerHTML).toBe('未选中态');
164167
});
165168

166169
it(': closable', () => {

0 commit comments

Comments
 (0)