From a5dd400be250c5ba18d0d789b2bb474c32b001f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com>
Date: Fri, 13 Dec 2024 20:59:35 +0800
Subject: [PATCH] chore: add test case
---
src/table/__tests__/base.test.jsx | 51 +++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/src/table/__tests__/base.test.jsx b/src/table/__tests__/base.test.jsx
index 8adf095cbe..d68e93a13f 100644
--- a/src/table/__tests__/base.test.jsx
+++ b/src/table/__tests__/base.test.jsx
@@ -561,5 +561,56 @@ TABLES.forEach((TTable) => {
expect(wrapper.find('.t-table__top-content').text()).toBe(topContentText);
});
});
+
+ describe(':props.filterIcon', () => {
+ it('props.filterIcon could be function', async () => {
+ const filterIconText = () => '筛';
+ const filterColumns = SIMPLE_COLUMNS.map((item) => ({
+ ...item,
+ filter: { type: 'single', list: [{ label: 1, value: 2 }] },
+ }));
+
+ const wrapper = mount({
+ render() {
+ return ;
+ },
+ });
+
+ if (TTable.name == 'TBaseTable') {
+ expect(wrapper.find('.t-table__filter-icon').exists()).toBeFalsy();
+ } else {
+ expect(wrapper.find('.t-table__filter-icon').exists()).toBeTruthy();
+ expect(wrapper.find('.t-table__filter-icon').text()).toBe(filterIconText());
+ }
+ });
+
+ it('slots.filter-icon works fine', () => {
+ const filterIconText = (rowKey) => '筛' + rowKey;
+ const filterColumns = SIMPLE_COLUMNS.map((item) => ({
+ ...item,
+ filter: { type: 'single', list: [{ label: 1, value: 2 }] },
+ }));
+ const wrapper = mount({
+ render() {
+ return (
+ filterIconText(col.col.colKey) }}
+ rowKey="index"
+ data={data}
+ columns={filterColumns}
+ >
+ );
+ },
+ });
+ if (TTable.name == 'TBaseTable') {
+ expect(wrapper.find('.t-table__filter-icon').exists()).toBeFalsy();
+ } else {
+ expect(wrapper.find('.t-table__filter-icon').exists()).toBeTruthy();
+ SIMPLE_COLUMNS.forEach((item, index) => {
+ expect(wrapper.findAll('.t-table__filter-icon').at(index).text()).toBe(filterIconText(item.colKey));
+ });
+ }
+ });
+ });
});
});