-
Notifications
You must be signed in to change notification settings - Fork 7
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
zereight
committed
Jul 12, 2021
1 parent
d23a239
commit 569e8a3
Showing
1 changed file
with
37 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// import "@testing-library/jest-dom/extend-expect"; | ||
// import { render } from "@testing-library/react"; | ||
|
||
import { getTimeDifference } from "../../utils/time"; | ||
|
||
describe("Time Util", () => { | ||
test("getTimeDifference", () => { | ||
const beforeThirtySeconds = new Date(); | ||
beforeThirtySeconds.setSeconds(beforeThirtySeconds.getSeconds() - 1); | ||
|
||
const beforeOneMinute = new Date(); | ||
beforeOneMinute.setMinutes(beforeOneMinute.getMinutes() - 1); | ||
|
||
const beforeOneHour = new Date(); | ||
beforeOneHour.setHours(beforeOneHour.getHours() - 1); | ||
|
||
const beforeOneDay = new Date(); | ||
beforeOneDay.setDate(beforeOneDay.getDate() - 1); | ||
|
||
const beforeOneWeek = new Date(); | ||
beforeOneWeek.setDate(beforeOneDay.getDate() - 7); | ||
|
||
const beforeOneMonth = new Date(); | ||
beforeOneMonth.setMonth(beforeOneMonth.getMonth() - 1); | ||
|
||
const beforeOneYear = new Date(); | ||
beforeOneYear.setFullYear(beforeOneYear.getFullYear() - 1); | ||
|
||
expect(getTimeDifference(beforeThirtySeconds.toString())).toEqual("방금 전"); | ||
expect(getTimeDifference(beforeOneMinute.toString())).toEqual("1분 전"); | ||
expect(getTimeDifference(beforeOneHour.toString())).toEqual("1시간 전"); | ||
expect(getTimeDifference(beforeOneDay.toString())).toEqual("1일 전"); | ||
expect(getTimeDifference(beforeOneWeek.toString())).toEqual("1주 전"); | ||
expect(getTimeDifference(beforeOneMonth.toString())).toEqual("1개월 전"); | ||
expect(getTimeDifference(beforeOneYear.toString())).toEqual("1년 전"); | ||
}); | ||
}); |