/** * Property-Based Test: Note Count Badge Formatting * * Feature: ivanti-queue-remediation * Property 12: Note count badge formatting * * For any integer count N where N > 0, the badge display SHALL show the string * representation of N when N <= 99, and "99+" when N > 99. For N = 0, no badge * SHALL be displayed. * * **Validates: Requirements 6.1, 6.2** */ import fc from 'fast-check'; // --------------------------------------------------------------------------- // Pure function under test — extracted badge display logic // --------------------------------------------------------------------------- /** * Determines the badge display value for a given note count. * Returns null when no badge should be shown (count = 0). * * @param {number} count - The number of remediation notes * @returns {string|null} The badge text, or null if no badge */ function formatBadgeCount(count) { if (count <= 0) return null; if (count > 99) return '99+'; return String(count); } // --------------------------------------------------------------------------- // Property 12: Note count badge formatting // --------------------------------------------------------------------------- describe('Feature: ivanti-queue-remediation, Property 12: Note count badge formatting', () => { it('displays the exact count for N where 1 <= N <= 99', () => { fc.assert( fc.property( fc.integer({ min: 1, max: 99 }), (count) => { const badge = formatBadgeCount(count); expect(badge).toBe(String(count)); } ), { numRuns: 100 } ); }); it('displays "99+" for any count exceeding 99', () => { fc.assert( fc.property( fc.integer({ min: 100, max: 100000 }), (count) => { const badge = formatBadgeCount(count); expect(badge).toBe('99+'); } ), { numRuns: 100 } ); }); it('returns null (no badge) for count = 0', () => { const badge = formatBadgeCount(0); expect(badge).toBeNull(); }); it('returns null (no badge) for negative counts', () => { fc.assert( fc.property( fc.integer({ min: -1000, max: 0 }), (count) => { const badge = formatBadgeCount(count); expect(badge).toBeNull(); } ), { numRuns: 100 } ); }); });