Commit 2f6ad04
authored
fix(test): handle 0/-0 in getComparator anti-symmetry property test (#308)
## Summary
Fixes the unit test failure on main after merging #306:
https://github.com/getsentry/cli/actions/runs/22508163174/job/65211393828
**Failing test:** `property: getComparator > comparator is
anti-symmetric: sign(cmp(a,b)) === -sign(cmp(b,a))`
**Root cause:** Bun's `expect().toBe()` uses `Object.is()` which
distinguishes `+0` from `-0`. When two generated issues have identical
sort fields (e.g., same `lastSeen`, same `count`, same `userCount`), the
comparator returns `0` for both `cmp(a,b)` and `cmp(b,a)`. However,
`Math.sign(0)` is `+0` and `-Math.sign(0)` is `-0`, so `Object.is(0,
-0)` fails.
**Fix:** Use `ab + ba === 0` instead of `Math.sign(ab) ===
-Math.sign(ba)` — this correctly handles the `0/-0` edge case since `0 +
(-0) === 0`. Same fix was already applied to the `compareDates`
anti-symmetry test in the same file but was missed for `getComparator`.1 parent 5192fbd commit 2f6ad04
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
309 | 311 | | |
310 | 312 | | |
311 | 313 | | |
| |||
0 commit comments