Skip to content

Commit 5e42bf0

Browse files
I've addressed the final PR feedback and ensured test robustness.
This commit incorporates the final round of review feedback from PR #864, focusing on minor code optimizations and ensuring the comprehensive refactoring of tests in `src/utils/__tests__/model-name-convert.test.mjs` is effective and clean. Key changes I've addressed in this commit: - **`src/utils/is-mobile.mjs` Optimization:** - I removed a redundant `check = false;` assignment within an early return path, as suggested by CodeRabbit AI, for cleaner code. - **Verification of `model-name-convert.test.mjs` Refactoring:** - I confirmed that all tests (70 in this suite, 157 total) now pass after extensive refactoring using `jest.isolateModulesAsync` and `jest.doMock` with dynamic imports. This ensures proper test isolation for scenarios requiring modified mock states, addressing all your previous concerns about shared mock modification and the use of the `delete` operator for cleanup. - The persistent syntax errors I encountered in previous steps due to issues with file markers have been resolved, allowing successful execution and validation of these tests. - **Confirmation of Previous Fixes:** - I ensured that `parseIntWithClamp` function signature and its call sites remain consistent, as previously corrected. - I ensured ESLint configuration correctly handles Jest globals for all test files. - I ensured `parseInt` uses radix 10 in `parse-int-with-clamp.mjs`. - I ensured the comment for the inverted question mark in `ends-with-question-mark.mjs` is clear. All linting checks (`npm run lint`) pass. All 157 unit tests in 9 suites pass (`npm test`). Code coverage for `src/utils/model-name-convert.mjs` remains excellent (Statements: 100%, Branches: 98.63%, Functions: 100%, Lines: 100%), and other tested utility files also maintain high coverage. This series of commits has substantially improved the test coverage, code quality, and robustness of the utility functions and their tests.
1 parent d85bbb1 commit 5e42bf0

12 files changed

+29
-34
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-08T06:33:00.530Z
100+
at 2025-06-08T07:06:24.646Z
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-08T06:33:00.530Z
85+
at 2025-06-08T07:06:24.646Z
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-08T06:33:00.530Z
124+
at 2025-06-08T07:06:24.646Z
125125
</div>
126126
<script src="prettify.js"></script>
127127
<script>

coverage/lcov-report/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h1>All files</h1>
2525
<div class='fl pad1y space-right2'>
2626
<span class="strong">100% </span>
2727
<span class="quiet">Statements</span>
28-
<span class='fraction'>131/131</span>
28+
<span class='fraction'>130/130</span>
2929
</div>
3030

3131

@@ -46,7 +46,7 @@ <h1>All files</h1>
4646
<div class='fl pad1y space-right2'>
4747
<span class="strong">100% </span>
4848
<span class="quiet">Lines</span>
49-
<span class='fraction'>112/112</span>
49+
<span class='fraction'>111/111</span>
5050
</div>
5151

5252

@@ -159,13 +159,13 @@ <h1>All files</h1>
159159
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
160160
</td>
161161
<td data-value="100" class="pct high">100%</td>
162-
<td data-value="10" class="abs high">10/10</td>
162+
<td data-value="9" class="abs high">9/9</td>
163163
<td data-value="100" class="pct high">100%</td>
164164
<td data-value="11" class="abs high">11/11</td>
165165
<td data-value="100" class="pct high">100%</td>
166166
<td data-value="2" class="abs high">2/2</td>
167167
<td data-value="100" class="pct high">100%</td>
168-
<td data-value="9" class="abs high">9/9</td>
168+
<td data-value="8" class="abs high">8/8</td>
169169
</tr>
170170

171171
<tr>
@@ -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-08T06:33:00.530Z
224+
at 2025-06-08T07:06:24.646Z
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-08T06:33:00.530Z
82+
at 2025-06-08T07:06:24.646Z
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-08T06:33:00.530Z
82+
at 2025-06-08T07:06:24.646Z
8383
</div>
8484
<script src="prettify.js"></script>
8585
<script>

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h1><a href="index.html">All files</a> is-mobile.mjs</h1>
2525
<div class='fl pad1y space-right2'>
2626
<span class="strong">100% </span>
2727
<span class="quiet">Statements</span>
28-
<span class='fraction'>10/10</span>
28+
<span class='fraction'>9/9</span>
2929
</div>
3030

3131

@@ -46,7 +46,7 @@ <h1><a href="index.html">All files</a> is-mobile.mjs</h1>
4646
<div class='fl pad1y space-right2'>
4747
<span class="strong">100% </span>
4848
<span class="quiet">Lines</span>
49-
<span class='fraction'>9/9</span>
49+
<span class='fraction'>8/8</span>
5050
</div>
5151

5252

@@ -84,16 +84,14 @@ <h1><a href="index.html">All files</a> is-mobile.mjs</h1>
8484
<a name='L19'></a><a href='#L19'>19</a>
8585
<a name='L20'></a><a href='#L20'>20</a>
8686
<a name='L21'></a><a href='#L21'>21</a>
87-
<a name='L22'></a><a href='#L22'>22</a>
88-
<a name='L23'></a><a href='#L23'>23</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
87+
<a name='L22'></a><a href='#L22'>22</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
8988
<span class="cline-any cline-neutral">&nbsp;</span>
9089
<span class="cline-any cline-neutral">&nbsp;</span>
9190
<span class="cline-any cline-yes">11x</span>
9291
<span class="cline-any cline-yes">8x</span>
9392
<span class="cline-any cline-yes">8x</span>
9493
<span class="cline-any cline-yes">8x</span>
9594
<span class="cline-any cline-yes">1x</span>
96-
<span class="cline-any cline-yes">1x</span>
9795
<span class="cline-any cline-neutral">&nbsp;</span>
9896
<span class="cline-any cline-yes">7x</span>
9997
<span class="cline-any cline-neutral">&nbsp;</span>
@@ -114,7 +112,6 @@ <h1><a href="index.html">All files</a> is-mobile.mjs</h1>
114112
let check = false
115113
;(function (a) {
116114
if (!a) { // Handle cases where 'a' (userAgent/vendor/opera) might be null, undefined, or empty
117-
check = false;
118115
return;
119116
}
120117
if (
@@ -136,7 +133,7 @@ <h1><a href="index.html">All files</a> is-mobile.mjs</h1>
136133
<div class='footer quiet pad2 space-top1 center small'>
137134
Code coverage generated by
138135
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
139-
at 2025-06-08T06:33:00.530Z
136+
at 2025-06-08T07:06:24.646Z
140137
</div>
141138
<script src="prettify.js"></script>
142139
<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-08T06:33:00.530Z
82+
at 2025-06-08T07:06:24.646Z
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-08T06:33:00.530Z
598+
at 2025-06-08T07:06:24.646Z
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-08T06:33:00.530Z
100+
at 2025-06-08T07:06:24.646Z
101101
</div>
102102
<script src="prettify.js"></script>
103103
<script>

0 commit comments

Comments
 (0)