Skip to content

Stabilize unit tests #228

@obecker

Description

@obecker

When trying to contribute to this project, I was very surprised to see that a lot of unit tests are failing.

After digging into the code I realized that this results most probably from using current dates in the tests.
However, this is a problem because a year in reality has a different amount of millis depending on the current date, but a year in prettytime has always 31556925960 millis (about 365,242 days).
So current date minus 1 year will format as "one year ago" in a leap year (i.e. the duration contains the leap day),
but as "12 months ago" in all other years.

To fix this all tests should be based on defined dates, so they will produces the same results no matter when the tests are executed.

See the adjusted test in #229 as an example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions