-
Notifications
You must be signed in to change notification settings - Fork 5
Develop #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { formatLocalDateString, isSameDate, isToday, getTodayLocalString } from '../utils'; | ||
| import { formatLocalDateString, isSameDate, isToday, getTodayLocalString, safeFormatTimestamp, getColorFromString, getInitials } from '../utils'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check for safeFormatTimestamp tests in the test file
rg -n "safeFormatTimestamp" src/lib/__tests__/utils.test.ts -C 5Repository: Resgrid/Responder Length of output: 440 🏁 Script executed: #!/bin/bash
# Also check the entire test file to see all test cases
wc -l src/lib/__tests__/utils.test.ts && echo "---" && cat -n src/lib/__tests__/utils.test.ts | tail -100Repository: Resgrid/Responder Length of output: 4075 🏁 Script executed: #!/bin/bash
# Search for the utils implementation to understand what safeFormatTimestamp does
cat -n src/lib/utils.ts | grep -A 20 "safeFormatTimestamp"Repository: Resgrid/Responder Length of output: 877 Add test cases for The function is imported but has no test coverage. Add tests for various scenarios: valid timestamps with different formats, null/undefined inputs, and error handling for invalid timestamps. 🤖 Prompt for AI Agents |
||
|
|
||
| describe('Date Utility Functions', () => { | ||
| describe('formatLocalDateString', () => { | ||
|
|
@@ -205,4 +205,45 @@ describe('Date Utility Functions', () => { | |
| expect(() => formatLocalDateString(validDate)).not.toThrow(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getColorFromString', () => { | ||
| it('generates deterministic color from string', () => { | ||
| const color1 = getColorFromString('test-string'); | ||
| const color2 = getColorFromString('test-string'); | ||
| expect(color1).toBe(color2); | ||
| expect(color1).toMatch(/^hsl\(\d+, 65%, 45%\)$/); | ||
| }); | ||
|
|
||
| it('generates different colors for different strings', () => { | ||
| const color1 = getColorFromString('string-1'); | ||
| const color2 = getColorFromString('string-2'); | ||
| expect(color1).not.toBe(color2); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getInitials', () => { | ||
| it('returns initials from first and last name', () => { | ||
| expect(getInitials('John', 'Doe')).toBe('JD'); | ||
| }); | ||
|
|
||
| it('handles missing first name', () => { | ||
| expect(getInitials(undefined, 'Doe')).toBe('D'); | ||
| }); | ||
|
|
||
| it('handles missing last name', () => { | ||
| expect(getInitials('John')).toBe('J'); | ||
| }); | ||
|
|
||
| it('handles empty strings', () => { | ||
| expect(getInitials('', '')).toBe('?'); | ||
| }); | ||
|
|
||
| it('handles extra whitespace', () => { | ||
| expect(getInitials(' John ', ' Doe ')).toBe('JD'); | ||
| }); | ||
|
|
||
| it('returns ? for no input', () => { | ||
| expect(getInitials()).toBe('?'); | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.