Skip to content

Commit f2203c1

Browse files
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

16 files changed

+355
-2257
lines changed

coverage/lcov-report/ends-with-question-mark.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ <h1><a href="index.html">All files</a> ends-with-question-mark.mjs</h1>
9797
<div class='footer quiet pad2 space-top1 center small'>
9898
Code coverage generated by
9999
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
100-
at 2025-06-07T14:07:35.126Z
100+
at 2025-06-07T18:05:22.712Z
101101
</div>
102102
<script src="prettify.js"></script>
103103
<script>

coverage/lcov-report/get-client-position.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ <h1><a href="index.html">All files</a> get-client-position.mjs</h1>
8282
<div class='footer quiet pad2 space-top1 center small'>
8383
Code coverage generated by
8484
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
85-
at 2025-06-07T14:07:35.126Z
85+
at 2025-06-07T18:05:22.712Z
8686
</div>
8787
<script src="prettify.js"></script>
8888
<script>

coverage/lcov-report/get-conversation-pairs.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ <h1><a href="index.html">All files</a> get-conversation-pairs.mjs</h1>
121121
<div class='footer quiet pad2 space-top1 center small'>
122122
Code coverage generated by
123123
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
124-
at 2025-06-07T14:07:35.126Z
124+
at 2025-06-07T18:05:22.712Z
125125
</div>
126126
<script src="prettify.js"></script>
127127
<script>

coverage/lcov-report/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ <h1>All files</h1>
221221
<div class='footer quiet pad2 space-top1 center small'>
222222
Code coverage generated by
223223
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
224-
at 2025-06-07T14:07:35.126Z
224+
at 2025-06-07T18:05:22.712Z
225225
</div>
226226
<script src="prettify.js"></script>
227227
<script>

coverage/lcov-report/is-edge.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h1><a href="index.html">All files</a> is-edge.mjs</h1>
7979
<div class='footer quiet pad2 space-top1 center small'>
8080
Code coverage generated by
8181
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
82-
at 2025-06-07T14:07:35.126Z
82+
at 2025-06-07T18:05:22.712Z
8383
</div>
8484
<script src="prettify.js"></script>
8585
<script>

coverage/lcov-report/is-firefox.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h1><a href="index.html">All files</a> is-firefox.mjs</h1>
7979
<div class='footer quiet pad2 space-top1 center small'>
8080
Code coverage generated by
8181
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
82-
at 2025-06-07T14:07:35.126Z
82+
at 2025-06-07T18:05:22.712Z
8383
</div>
8484
<script src="prettify.js"></script>
8585
<script>

coverage/lcov-report/is-mobile.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ <h1><a href="index.html">All files</a> is-mobile.mjs</h1>
124124
<div class='footer quiet pad2 space-top1 center small'>
125125
Code coverage generated by
126126
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
127-
at 2025-06-07T14:07:35.126Z
127+
at 2025-06-07T18:05:22.712Z
128128
</div>
129129
<script src="prettify.js"></script>
130130
<script>

coverage/lcov-report/is-safari.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h1><a href="index.html">All files</a> is-safari.mjs</h1>
7979
<div class='footer quiet pad2 space-top1 center small'>
8080
Code coverage generated by
8181
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
82-
at 2025-06-07T14:07:35.126Z
82+
at 2025-06-07T18:05:22.712Z
8383
</div>
8484
<script src="prettify.js"></script>
8585
<script>

coverage/lcov-report/model-name-convert.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ <h1><a href="index.html">All files</a> model-name-convert.mjs</h1>
595595
<div class='footer quiet pad2 space-top1 center small'>
596596
Code coverage generated by
597597
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
598-
at 2025-06-07T14:07:35.126Z
598+
at 2025-06-07T18:05:22.712Z
599599
</div>
600600
<script src="prettify.js"></script>
601601
<script>

coverage/lcov-report/parse-int-with-clamp.mjs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ <h1><a href="index.html">All files</a> parse-int-with-clamp.mjs</h1>
9797
<div class='footer quiet pad2 space-top1 center small'>
9898
Code coverage generated by
9999
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
100-
at 2025-06-07T14:07:35.126Z
100+
at 2025-06-07T18:05:22.712Z
101101
</div>
102102
<script src="prettify.js"></script>
103103
<script>

0 commit comments

Comments
 (0)