-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
import { displayDate } from './datetime' | ||
import { isToday } from './datetime' | ||
|
||
import { displayDate } from './datetime'; | ||
import { isToday } from './datetime'; | ||
|
||
test('should return only time for today\'s timestamp', () => { | ||
const today = new Date(); | ||
const timestamp = today.getTime(); | ||
const expectedTime = today.toLocaleTimeString(undefined, { | ||
test("should return only time for today's timestamp", () => { | ||
const today = new Date() | ||
const timestamp = today.getTime() | ||
const expectedTime = `${today.toLocaleDateString(undefined, { | ||
day: '2-digit', | ||
month: 'short', | ||
year: 'numeric', | ||
})}, ${today.toLocaleTimeString(undefined, { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
second: '2-digit', | ||
hour12: true, | ||
}); | ||
expect(displayDate(timestamp)).toBe(expectedTime); | ||
}); | ||
|
||
})}` | ||
expect(displayDate(timestamp / 1000)).toBe(expectedTime) | ||
}) | ||
|
||
test('should return N/A for undefined timestamp', () => { | ||
expect(displayDate()).toBe('N/A'); | ||
}); | ||
|
||
expect(displayDate()).toBe('N/A') | ||
}) | ||
|
||
test('should return true for today\'s timestamp', () => { | ||
const today = new Date(); | ||
const timestamp = today.setHours(0, 0, 0, 0); | ||
expect(isToday(timestamp)).toBe(true); | ||
}); | ||
test("should return true for today's timestamp", () => { | ||
const today = new Date() | ||
const timestamp = today.setHours(0, 0, 0, 0) | ||
expect(isToday(timestamp)).toBe(true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters