test: improve test structure
This commit is contained in:
parent
179d51d408
commit
d4cf3e8de6
1 changed files with 64 additions and 29 deletions
|
@ -9,37 +9,72 @@ describe("getAge tests", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test("isOverBirthDay to work", () => {
|
test("isOverBirthDay to work", () => {
|
||||||
expect(
|
const testCases: {
|
||||||
isOverBirthDay(new Date("2022-12-31, 00:00:00.000 +09:00"))
|
timestamp: string
|
||||||
).toEqual(true)
|
overBD: boolean
|
||||||
|
year: number
|
||||||
|
monthIndex: number
|
||||||
|
date: number
|
||||||
|
}[] = [
|
||||||
|
{
|
||||||
|
timestamp: "2022-12-31, 00:00:00.000 +09:00",
|
||||||
|
overBD: true,
|
||||||
|
year: 2022,
|
||||||
|
monthIndex: 11,
|
||||||
|
date: 31,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamp: "2023-01-01, 00:00:00.000 +09:00",
|
||||||
|
overBD: false,
|
||||||
|
year: 2023,
|
||||||
|
monthIndex: 0,
|
||||||
|
date: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamp: "2023-07-29, 00:00:00.000 +09:00",
|
||||||
|
overBD: false,
|
||||||
|
year: 2023,
|
||||||
|
monthIndex: 6,
|
||||||
|
date: 29,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamp: "2023-07-30, 00:00:00.000 +09:00",
|
||||||
|
overBD: true,
|
||||||
|
year: 2023,
|
||||||
|
monthIndex: 6,
|
||||||
|
date: 30,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamp: "2023-07-31, 00:00:00.000 +09:00",
|
||||||
|
overBD: true,
|
||||||
|
year: 2023,
|
||||||
|
monthIndex: 6,
|
||||||
|
date: 31,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamp: "2023-12-31, 00:00:00.000 +09:00",
|
||||||
|
overBD: true,
|
||||||
|
year: 2023,
|
||||||
|
monthIndex: 11,
|
||||||
|
date: 31,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamp: "2024-01-01, 00:00:00.000 +09:00",
|
||||||
|
overBD: false,
|
||||||
|
year: 2024,
|
||||||
|
monthIndex: 0,
|
||||||
|
date: 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
expect(
|
for (const testCase of testCases) {
|
||||||
isOverBirthDay(new Date("2023-01-01, 00:00:00.000 +09:00"))
|
const date = new Date(testCase.timestamp)
|
||||||
).toEqual(false)
|
|
||||||
|
|
||||||
//
|
expect(date.getFullYear()).toEqual(testCase.year)
|
||||||
|
expect(date.getMonth()).toEqual(testCase.monthIndex)
|
||||||
expect(
|
expect(date.getDate()).toEqual(testCase.date)
|
||||||
isOverBirthDay(new Date("2023-07-29, 00:00:00.000 +09:00"))
|
expect(isOverBirthDay(date)).toEqual(testCase.overBD)
|
||||||
).toEqual(false)
|
}
|
||||||
|
|
||||||
expect(
|
|
||||||
isOverBirthDay(new Date("2023-07-30, 00:00:00.000 +09:00"))
|
|
||||||
).toEqual(true)
|
|
||||||
|
|
||||||
expect(
|
|
||||||
isOverBirthDay(new Date("2023-07-31, 00:00:00.000 +09:00"))
|
|
||||||
).toEqual(true)
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
expect(
|
|
||||||
isOverBirthDay(new Date("2023-12-31, 00:00:00.000 +09:00"))
|
|
||||||
).toEqual(true)
|
|
||||||
|
|
||||||
expect(
|
|
||||||
isOverBirthDay(new Date("2024-01-01, 00:00:00.000 +09:00"))
|
|
||||||
).toEqual(false)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test("dateFormatOption to work properly", () => {
|
test("dateFormatOption to work properly", () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue