Files
outline/shared/utils/TextHelper.test.ts
Tom Moor d8fbe35455 fix: Template variables are not applied on client (#8044)
* fix: Template variables are not applied on client

* test
2024-11-30 07:13:44 -08:00

32 lines
778 B
TypeScript

import { TextHelper } from "./TextHelper";
describe("TextHelper", () => {
beforeAll(() => {
jest.useFakeTimers();
jest.setSystemTime(Date.parse("2021-01-01T00:00:00.000Z"));
});
afterAll(() => {
jest.useRealTimers();
});
describe("replaceTemplateVariables", () => {
const user = {
name: "John Doe",
language: "en",
};
it("should replace {time} with current time", async () => {
const result = TextHelper.replaceTemplateVariables("Hello {time}", user);
expect(result).toBe("Hello 12:00 AM");
});
it("should replace {date} with current date", async () => {
const result = TextHelper.replaceTemplateVariables("Hello {date}", user);
expect(result).toBe("Hello January 1, 2021");
});
});
});