2023-10-23 23:11:59 +02:00
|
|
|
import { getAge } from "@/utils/getAge"
|
2022-07-28 22:51:12 +02:00
|
|
|
|
2023-10-23 23:11:59 +02:00
|
|
|
describe("utils/getAge", () => {
|
|
|
|
it("should calculate the right age of a person", () => {
|
|
|
|
cy.clock(new Date("2018-03-20")).then(() => {
|
|
|
|
const birthDate = new Date("1980-02-20")
|
2022-07-28 22:51:12 +02:00
|
|
|
expect(getAge(birthDate)).equal(38)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2023-10-23 23:11:59 +02:00
|
|
|
it("should calculate the right age of a person (taking into account the months)", () => {
|
|
|
|
cy.clock(new Date("2018-03-20")).then(() => {
|
|
|
|
const birthDate = new Date("1980-07-20")
|
2022-07-28 22:51:12 +02:00
|
|
|
expect(getAge(birthDate)).equal(37)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|