utils/numbers: fix test

This commit is contained in:
Alex Gleason 2022-07-06 11:36:01 -05:00
parent cc4c8a0188
commit 8685b64f9d
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 6 additions and 6 deletions

View File

@ -10,28 +10,28 @@ test('isIntegerId()', () => {
expect(isIntegerId('-1764036199')).toBe(true);
expect(isIntegerId('106801667066418367')).toBe(true);
expect(isIntegerId('9v5bmRalQvjOy0ECcC')).toBe(false);
expect(isIntegerId(null)).toBe(false);
expect(isIntegerId(undefined)).toBe(false);
expect(isIntegerId(null as any)).toBe(false);
expect(isIntegerId(undefined as any)).toBe(false);
});
describe('shortNumberFormat', () => {
test('handles non-numbers', () => {
render(<div data-testid='num'>{shortNumberFormat('not-number')}</div>, null, null);
render(<div data-testid='num'>{shortNumberFormat('not-number')}</div>, undefined, null);
expect(screen.getByTestId('num')).toHaveTextContent('•');
});
test('formats numbers under 1,000', () => {
render(<div data-testid='num'>{shortNumberFormat(555)}</div>, null, null);
render(<div data-testid='num'>{shortNumberFormat(555)}</div>, undefined, null);
expect(screen.getByTestId('num')).toHaveTextContent('555');
});
test('formats numbers under 1,000,000', () => {
render(<div data-testid='num'>{shortNumberFormat(5555)}</div>, null, null);
render(<div data-testid='num'>{shortNumberFormat(5555)}</div>, undefined, null);
expect(screen.getByTestId('num')).toHaveTextContent('5.6K');
});
test('formats numbers over 1,000,000', () => {
render(<div data-testid='num'>{shortNumberFormat(5555555)}</div>, null, null);
render(<div data-testid='num'>{shortNumberFormat(5555555)}</div>, undefined, null);
expect(screen.getByTestId('num')).toHaveTextContent('5.6M');
});
});