Skip to content

Commit d504104

Browse files
Copilotpethers
andcommitted
refactor: consolidate assertions and add rounding boundary tests
- Consolidate repetitive undefined checks using Object.values().every() - Add explicit rounding boundary tests (.49 and .50) for formatCurrency - All 212 tests passing with improved test maintainability Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
1 parent 772e089 commit d504104

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/constants/appConstants.test.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,13 @@ describe("Application Constants", () => {
170170
it("returns undefined values when options is null", () => {
171171
const result = mapOptionsToConstants(null as unknown as Record<string, CIADetails>, "description");
172172

173-
expect(result.NONE).toBeUndefined();
174-
expect(result.LOW).toBeUndefined();
175-
expect(result.MODERATE).toBeUndefined();
176-
expect(result.HIGH).toBeUndefined();
177-
expect(result.VERY_HIGH).toBeUndefined();
173+
expect(Object.values(result).every(v => v === undefined)).toBe(true);
178174
});
179175

180176
it("returns undefined values when options is undefined", () => {
181177
const result = mapOptionsToConstants(undefined as unknown as Record<string, CIADetails>, "description");
182178

183-
expect(result.NONE).toBeUndefined();
184-
expect(result.LOW).toBeUndefined();
185-
expect(result.MODERATE).toBeUndefined();
186-
expect(result.HIGH).toBeUndefined();
187-
expect(result.VERY_HIGH).toBeUndefined();
179+
expect(Object.values(result).every(v => v === undefined)).toBe(true);
188180
});
189181

190182
it("maps description field correctly", () => {

src/constants/costConstants.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ describe("costConstants", () => {
310310
expect(formatted).toContain("1,235");
311311
});
312312

313+
it("rounds down correctly at .49 boundary", () => {
314+
const formatted = formatCurrency(1234.49);
315+
expect(formatted).toContain("$");
316+
expect(formatted).toContain("1,234");
317+
});
318+
319+
it("rounds up correctly at .50 boundary", () => {
320+
const formatted = formatCurrency(1234.50);
321+
expect(formatted).toContain("$");
322+
expect(formatted).toContain("1,235");
323+
});
324+
313325
it("uses default USD when no currency specified", () => {
314326
const formatted = formatCurrency(500);
315327
expect(formatted).toContain("$");

0 commit comments

Comments
 (0)