Commit 035ce9f
authored
Fix: correct bugs in test files (#1418)
### Summary
Fixed 6 bugs across 6 test files discovered during code review. All issues were in test code only — no library changes.
### Changes
#### 1. `test/client_setup.js` — Remove reference to undefined `timer`
The `SIGINT` handler called `timer.cancel()`, but `timer` is not defined in this scope. Removed the call to prevent a `ReferenceError` if the signal is received.
#### 2. `test/test-lifecycle.js` — Fix duplicate transition index
Two consecutive assertions both checked `transitions[1]`, meaning `transitions[2]` was never validated. Changed the second check from `transitions[1]` to `transitions[2]`.
#### 3. `test/test-parameter-service.js` — Fix wrong parameter name
`Parameter.fromParameterMessage` was called with `name: 'p1'` but the test was validating parameter `A.p3`. Changed to `name: 'A.p3'`.
#### 4. `test/test-rate.js` — Add missing assertion
The test computed an average sleep time but never asserted on it. Added an assertion that the average is within 5x the expected period.
#### 5. `test/test-utils.js` — Remove empty duplicate test
An empty test body `it('should valid ensureDirSync works correctly', function () {})` duplicated the immediately following test `it('should verify ensureDirSync works correctly', ...)`. Removed the empty duplicate.
#### 6. `test/types/index.test-d.ts` — Remove misplaced type assertion
`expectType<boolean>(client.isServiceServerAvailable())` was in the **ActionClient** section but tested `client` (the service client variable). The same assertion already exists in the correct Client section. Removed the misplaced copy.
### Files changed
| File | Change |
|------|--------|
| `test/client_setup.js` | Remove undefined `timer.cancel()` |
| `test/test-lifecycle.js` | `transitions[1]` → `transitions[2]` in second assertion |
| `test/test-parameter-service.js` | `'p1'` → `'A.p3'` |
| `test/test-rate.js` | Add avg sleep time assertion |
| `test/test-utils.js` | Remove empty duplicate test |
| `test/types/index.test-d.ts` | Remove misplaced `client.isServiceServerAvailable()` |
Fix: #14171 parent ba6f9a5 commit 035ce9f
6 files changed
Lines changed: 11 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
264 | | - | |
265 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
110 | 117 | | |
111 | 118 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | 48 | | |
51 | 49 | | |
52 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
476 | 475 | | |
477 | 476 | | |
478 | 477 | | |
| |||
0 commit comments