Commit f2203c1
committed
Refactor tests and fix issues based on review feedback
This commit addresses several points raised during code review of the previously added unit tests:
- **Dependency Update:**
- Updated `babel-jest` in `package.json` from beta version `^30.0.0-beta.3` to stable `^29.7.0` and ran `npm install`.
- **Bug Fix - `parseIntWithClamp` Call Sites:**
- Corrected the parameter order in the two call sites of `parseIntWithClamp` in `src/popup/sections/AdvancedPart.jsx` to match the updated function signature `(value, min, max, defaultValue)`. This fixes a runtime bug where min/max/default values would have been misinterpreted.
- **Test Code Refinements:**
- `src/utils/__tests__/is-edge.test.mjs`: Simplified comments in the legacy Edge user agent test for clarity. The test logic was already correct.
- `src/utils/__tests__/is-firefox.test.mjs`:
- Refactored `navigator.userAgent` mocking. The `beforeEach` now correctly defines `navigator.userAgent` as a configurable property with a getter/setter before `jest.spyOn(..., 'get')` is called.
- The `afterEach` block now correctly restores the spy and the original `userAgent` property descriptor. This resolved test failures caused by the previous simplification attempt.
- `src/utils/__tests__/model-name-convert.test.mjs`: Replaced two instances of the `delete` operator with direct assignment to `undefined` (e.g., `actualMockModels['claude'] = undefined;`) for performance reasons.
- **ESLint Configuration:**
- Verified that the ESLint configuration (`.eslintrc.json`) correctly includes an override for test files (`src/utils/__tests__/**/*.mjs`, `*.test.mjs`) with `env: { jest: true, node: true }`. This ensures Jest global variables are recognized by the linter.
All linters and unit tests pass after these changes.1 parent e456cd2 commit f2203c1
File tree
16 files changed
+355
-2257
lines changed- coverage/lcov-report
- src
- popup/sections
- utils/__tests__
16 files changed
+355
-2257
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
598 | | - | |
| 598 | + | |
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
0 commit comments