test(core): add unit tests for wait utility#4894
Conversation
Signed-off-by: Atulya Singh <atulyarajsingh@gmail.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
|
PR changed again? Review this PR in Change Stack to compare snapshots and stay oriented. 📝 WalkthroughWalkthroughThis PR adds two new Vitest test suites for utility functions. The first suite tests the ChangesTest coverage for utility functions
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/core/shell-quote.test.ts (1)
7-30: 💤 Low valueConsider adding test cases for non-string inputs.
The function signature accepts
unknownand usesString(value)conversion, but all current tests use string inputs. Adding test cases for numbers,null,undefined, and objects would verify the type conversion contract.🧪 Example test cases for non-string inputs
it("converts numbers to strings", () => { expect(shellQuote(42)).toBe("'42'"); }); it("converts null to string", () => { expect(shellQuote(null)).toBe("'null'"); }); it("converts undefined to string", () => { expect(shellQuote(undefined)).toBe("'undefined'"); }); it("converts objects to string", () => { expect(shellQuote({key: "value"})).toBe("'[object Object]'"); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/core/shell-quote.test.ts` around lines 7 - 30, Add tests covering non-string inputs to verify shellQuote accepts unknown and uses String(value); specifically add cases calling shellQuote with a number (e.g., 42), null, undefined, and an object (e.g., {key:"value"}) and assert the results are the single-quoted String(value) with proper escaping (e.g., "'42'", "'null'", "'undefined'", and the quoted "[object Object]" form); update src/lib/core/shell-quote.test.ts around the existing describe('shellQuote'...) block to include these new it(...) cases so they exercise the shellQuote function's type conversion and escaping behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/lib/core/shell-quote.test.ts`:
- Around line 7-30: Add tests covering non-string inputs to verify shellQuote
accepts unknown and uses String(value); specifically add cases calling
shellQuote with a number (e.g., 42), null, undefined, and an object (e.g.,
{key:"value"}) and assert the results are the single-quoted String(value) with
proper escaping (e.g., "'42'", "'null'", "'undefined'", and the quoted "[object
Object]" form); update src/lib/core/shell-quote.test.ts around the existing
describe('shellQuote'...) block to include these new it(...) cases so they
exercise the shellQuote function's type conversion and escaping behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f4142c87-cf72-411b-ac9f-fdc305efb457
📒 Files selected for processing (2)
src/lib/core/shell-quote.test.tssrc/lib/core/wait.test.ts
|
@atulya-singh mind adding a DCO to the PR description, please? |
|
Hi, I added the DCO to the PR description. |
Summary
src/lib/core/wait.test.tswith unit tests for all four functions insrc/lib/core/wait.tssleepMs,sleepSeconds,waitUntil,waitForPort, andwaitForHttperrno.test.tsandshell-quote.test.tsnode:child_processviavi.mockto testwaitForPortandwaitForHttpwithout real network callsTest plan
sleepMs: verifies blocking for positive durations and immediate return for zero/negative/NaN/InfinitysleepSeconds: verifies conversion from seconds to millisecondswaitUntil: covers immediate true, delayed true, timeout (false), and multi-poll behaviorwaitForPort: mockedspawnSync— success (status 0), timeout (status 1), and thrown exceptionwaitForHttp: mockedspawnSync— success (status 0), timeout (status 1), and thrown exceptionDCO
Signed-off-by: Atulya Singh atulyarajsingh@gmail.com