mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fixed bug; wrote tests (#5329)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { createDisplayDate } from "./TimelineDateRow"
|
||||
|
||||
describe("createDisplayDate", () => {
|
||||
it("returns correctly for Saturdays", () => {
|
||||
const date = new Date("Sat Dec 03 2022 00:00:00 GMT-0500")
|
||||
expect(createDisplayDate(date)).toEqual("last Saturday")
|
||||
})
|
||||
})
|
||||
@@ -8,16 +8,18 @@ export interface TimelineDateRow {
|
||||
date: Date
|
||||
}
|
||||
|
||||
// We only want the message related to the date since the time is displayed
|
||||
// inside of the build row
|
||||
export const createDisplayDate = (date: Date): string =>
|
||||
formatRelative(date, new Date()).split(" at ")[0]
|
||||
|
||||
export const TimelineDateRow: FC<TimelineDateRow> = ({ date }) => {
|
||||
const styles = useStyles()
|
||||
// We only want the message related to the date since the time is displayed
|
||||
// inside of the build row
|
||||
const displayDate = formatRelative(date, new Date()).split("at")[0]
|
||||
|
||||
return (
|
||||
<TableRow className={styles.dateRow}>
|
||||
<TableCell className={styles.dateCell} title={date.toLocaleDateString()}>
|
||||
{displayDate}
|
||||
{createDisplayDate(date)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user