Showing
5 changed files
with
26 additions
and
9 deletions
... | ... | @@ -86,7 +86,7 @@ |
86 | 86 | <div class='footer quiet pad2 space-top1 center small'> |
87 | 87 | Code coverage generated by |
88 | 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 | 90 | </div> |
91 | 91 | <script src="prettify.js"></script> |
92 | 92 | <script> | ... | ... |
... | ... | @@ -13,21 +13,22 @@ module.exports = { |
13 | 13 | coverageReporters: ["lcov", "text-summary"], // 配置覆盖率报告的格式 |
14 | 14 | rootDir: "./", |
15 | 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 | 20 | transform: { |
21 | 21 | "^.+\\.(ts|tsx)$": "ts-jest", |
22 | 22 | "^.+\\.(js|jsx)$": "babel-jest", |
23 | 23 | }, |
24 | - transformIgnorePatterns: ['/node_modules/'], | |
24 | + transformIgnorePatterns: ['^(?!(lodash-es).*$)(?=node_modules)'], | |
25 | 25 | |
26 | 26 | testRegex: "(/src/*/.*\\.(test|spec))\\.[tj]sx?$", |
27 | 27 | |
28 | 28 | moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"], |
29 | 29 | moduleNameMapper: { |
30 | 30 | "^.+\\.(css|less)$": "identity-obj-proxy", |
31 | + "^.+\\.(jpg|jpeg|png|gif|svg)$": '<rootDir>/mock/images/fileMock.js', | |
31 | 32 | "antd/es": "<rootDir>/node_modules/antd/dist/antd.min.js", |
32 | 33 | }, |
33 | 34 | testPathIgnorePatterns: ["<rootDir>/node_modules/"], | ... | ... |
mock/images/fileMock.js
0 → 100644
... | ... | @@ -22,6 +22,18 @@ import VarPicker from './var-picker'; |
22 | 22 | // }; |
23 | 23 | |
24 | 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 | 37 | describe('test component', () => { |
26 | 38 | test('click event', () => { |
27 | 39 | render( |
... | ... | @@ -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 | 177 | // userEvent.click(screen.getByTestId('clickBtn')); |
166 | 178 | // // 异步 |
167 | 179 | // await waitFor(() => { | ... | ... |
... | ... | @@ -45,12 +45,16 @@ export interface FunctionProps { |
45 | 45 | funcNameEg: string; |
46 | 46 | } |
47 | 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 | 53 | key: string; |
50 | 54 | titleStr?: string; |
51 | 55 | iconName?: string; |
52 | 56 | widget?: string; |
53 | - fieldGroupType?: FIELD_TYPE_PROPS; | |
57 | + fieldGroupType?: 'TEXT' | 'OBJECT' | 'DATE'; | |
54 | 58 | children?: ColsTreeSelectProps[]; |
55 | 59 | } |
56 | 60 | |
... | ... | @@ -64,7 +68,7 @@ interface QxFunOperationProps { |
64 | 68 | style?: any; |
65 | 69 | autofocus?: boolean; |
66 | 70 | fieldName: string; |
67 | - fieldType: FIELD_TYPE_PROPS; | |
71 | + fieldType: 'TEXT' | 'OBJECT' | 'DATE'; | |
68 | 72 | uniKey: string; |
69 | 73 | isScriptEditMode?: boolean; |
70 | 74 | isInSubForm?: boolean; | ... | ... |