Showing
5 changed files
with
26 additions
and
9 deletions
@@ -86,7 +86,7 @@ | @@ -86,7 +86,7 @@ | ||
86 | <div class='footer quiet pad2 space-top1 center small'> | 86 | <div class='footer quiet pad2 space-top1 center small'> |
87 | Code coverage generated by | 87 | Code coverage generated by |
88 | <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a> | 88 | <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a> |
89 | - at 2023-10-09T10:23:14.046Z | 89 | + at 2023-10-09T11:13:29.172Z |
90 | </div> | 90 | </div> |
91 | <script src="prettify.js"></script> | 91 | <script src="prettify.js"></script> |
92 | <script> | 92 | <script> |
@@ -13,21 +13,22 @@ module.exports = { | @@ -13,21 +13,22 @@ module.exports = { | ||
13 | coverageReporters: ["lcov", "text-summary"], // 配置覆盖率报告的格式 | 13 | coverageReporters: ["lcov", "text-summary"], // 配置覆盖率报告的格式 |
14 | rootDir: "./", | 14 | rootDir: "./", |
15 | modulePaths: ["<rootDir>/src/"], | 15 | modulePaths: ["<rootDir>/src/"], |
16 | - coveragePathIgnorePatterns: ["/node_modules/"], | ||
17 | - modulePathIgnorePatterns: ["/node_modules/"], | ||
18 | - watchPathIgnorePatterns: ["/node_modules/"], | 16 | + coveragePathIgnorePatterns: ["<rootDir>/node_modules/"], |
17 | + modulePathIgnorePatterns: ["<rootDir>/node_modules/"], | ||
18 | + watchPathIgnorePatterns: ["<rootDir>/node_modules/"], | ||
19 | 19 | ||
20 | transform: { | 20 | transform: { |
21 | "^.+\\.(ts|tsx)$": "ts-jest", | 21 | "^.+\\.(ts|tsx)$": "ts-jest", |
22 | "^.+\\.(js|jsx)$": "babel-jest", | 22 | "^.+\\.(js|jsx)$": "babel-jest", |
23 | }, | 23 | }, |
24 | - transformIgnorePatterns: ['/node_modules/'], | 24 | + transformIgnorePatterns: ['^(?!(lodash-es).*$)(?=node_modules)'], |
25 | 25 | ||
26 | testRegex: "(/src/*/.*\\.(test|spec))\\.[tj]sx?$", | 26 | testRegex: "(/src/*/.*\\.(test|spec))\\.[tj]sx?$", |
27 | 27 | ||
28 | moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"], | 28 | moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"], |
29 | moduleNameMapper: { | 29 | moduleNameMapper: { |
30 | "^.+\\.(css|less)$": "identity-obj-proxy", | 30 | "^.+\\.(css|less)$": "identity-obj-proxy", |
31 | + "^.+\\.(jpg|jpeg|png|gif|svg)$": '<rootDir>/mock/images/fileMock.js', | ||
31 | "antd/es": "<rootDir>/node_modules/antd/dist/antd.min.js", | 32 | "antd/es": "<rootDir>/node_modules/antd/dist/antd.min.js", |
32 | }, | 33 | }, |
33 | testPathIgnorePatterns: ["<rootDir>/node_modules/"], | 34 | testPathIgnorePatterns: ["<rootDir>/node_modules/"], |
mock/images/fileMock.js
0 → 100644
@@ -22,6 +22,18 @@ import VarPicker from './var-picker'; | @@ -22,6 +22,18 @@ import VarPicker from './var-picker'; | ||
22 | // }; | 22 | // }; |
23 | 23 | ||
24 | // "test": "jest --no-cache --config jest.config.js" | 24 | // "test": "jest --no-cache --config jest.config.js" |
25 | +jest.mock('@qx/utils', () => ({ | ||
26 | + getWidgetsIcon: () => <span>icon</span>, | ||
27 | +})); | ||
28 | + | ||
29 | +const getByTextWithFallback = (text: any) => { | ||
30 | + try { | ||
31 | + return screen.getByText(text); | ||
32 | + } catch (error) { | ||
33 | + // 如果无法找到精确的文本匹配,尝试使用包含文本的元素 | ||
34 | + return screen.getByRole('tree', { name: new RegExp(text) }); | ||
35 | + } | ||
36 | +}; | ||
25 | describe('test component', () => { | 37 | describe('test component', () => { |
26 | test('click event', () => { | 38 | test('click event', () => { |
27 | render( | 39 | render( |
@@ -161,7 +173,7 @@ describe('test component', () => { | @@ -161,7 +173,7 @@ describe('test component', () => { | ||
161 | />, | 173 | />, |
162 | ); | 174 | ); |
163 | 175 | ||
164 | - expect(screen.getByText('暂无数据')).toBeNull(); | 176 | + expect(screen.getByRole('tree')).not.toBeNull(); |
165 | // userEvent.click(screen.getByTestId('clickBtn')); | 177 | // userEvent.click(screen.getByTestId('clickBtn')); |
166 | // // 异步 | 178 | // // 异步 |
167 | // await waitFor(() => { | 179 | // await waitFor(() => { |
@@ -45,12 +45,16 @@ export interface FunctionProps { | @@ -45,12 +45,16 @@ export interface FunctionProps { | ||
45 | funcNameEg: string; | 45 | funcNameEg: string; |
46 | } | 46 | } |
47 | export interface ColsTreeSelectProps extends TreeDataNode { | 47 | export interface ColsTreeSelectProps extends TreeDataNode { |
48 | - attrs?: { titleStr: string; fieldGroupType: FIELD_TYPE_PROPS; key: string }[]; | 48 | + attrs?: { |
49 | + titleStr: string; | ||
50 | + fieldGroupType: 'TEXT' | 'OBJECT' | 'DATE'; | ||
51 | + key: string; | ||
52 | + }[]; | ||
49 | key: string; | 53 | key: string; |
50 | titleStr?: string; | 54 | titleStr?: string; |
51 | iconName?: string; | 55 | iconName?: string; |
52 | widget?: string; | 56 | widget?: string; |
53 | - fieldGroupType?: FIELD_TYPE_PROPS; | 57 | + fieldGroupType?: 'TEXT' | 'OBJECT' | 'DATE'; |
54 | children?: ColsTreeSelectProps[]; | 58 | children?: ColsTreeSelectProps[]; |
55 | } | 59 | } |
56 | 60 | ||
@@ -64,7 +68,7 @@ interface QxFunOperationProps { | @@ -64,7 +68,7 @@ interface QxFunOperationProps { | ||
64 | style?: any; | 68 | style?: any; |
65 | autofocus?: boolean; | 69 | autofocus?: boolean; |
66 | fieldName: string; | 70 | fieldName: string; |
67 | - fieldType: FIELD_TYPE_PROPS; | 71 | + fieldType: 'TEXT' | 'OBJECT' | 'DATE'; |
68 | uniKey: string; | 72 | uniKey: string; |
69 | isScriptEditMode?: boolean; | 73 | isScriptEditMode?: boolean; |
70 | isInSubForm?: boolean; | 74 | isInSubForm?: boolean; |