mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* wip * fix: Treat null expiresAt as no expiry when creating a share * fix: Add bottom padding to share notices
27 lines
857 B
TypeScript
27 lines
857 B
TypeScript
import { addDays, endOfDay, subDays } from "date-fns";
|
|
import i18next from "i18next";
|
|
import { daysToExpiry } from "./date";
|
|
|
|
describe("daysToExpiry", () => {
|
|
const instance = i18next.createInstance();
|
|
|
|
beforeAll(async () => {
|
|
await instance.init({ lng: "en_US", resources: {} });
|
|
});
|
|
|
|
it("should return the number of days until expiry", () => {
|
|
const date = endOfDay(addDays(new Date(), 3)).toISOString();
|
|
expect(daysToExpiry(date, instance.t)).toContain("3");
|
|
});
|
|
|
|
it("should return today when expiring today", () => {
|
|
const date = endOfDay(new Date()).toISOString();
|
|
expect(daysToExpiry(date, instance.t)).toEqual("Expires today");
|
|
});
|
|
|
|
it("should return expired when in the past", () => {
|
|
const date = subDays(new Date(), 1).toISOString();
|
|
expect(daysToExpiry(date, instance.t)).toEqual("Expired");
|
|
});
|
|
});
|