@koha-community/prettier-plugin-template-toolkit
Version:
Prettier plugin for formatting Template::Toolkit templates.
35 lines (31 loc) • 918 B
text/typescript
import { findPlaceholders } from "../src/printer";
test("findPlaceholders should find placeholder", () => {
expect(findPlaceholders("#~1~#")).toEqual([[0, 4]]);
expect(findPlaceholders("XX#~1~#XX")).toEqual([[2, 6]]);
});
test("findPlaceholders should find multiple placeholders", () => {
expect(findPlaceholders("#~1~##~99~#")).toEqual([
[],
[],
]);
expect(findPlaceholders("#~1~#X#~99~#")).toEqual([
[],
[],
]);
expect(findPlaceholders("#~1~##~X#~99~#")).toEqual([
[],
[],
[],
]);
expect(findPlaceholders("#~1~##~99~#~#")).toEqual([
[],
[],
]);
});
test("findPlaceholders should find no placeholders", () => {
expect(findPlaceholders("")).toEqual([]);
expect(findPlaceholders("#~#")).toEqual([]);
expect(findPlaceholders("#~ #")).toEqual([]);
expect(findPlaceholders("# ~#")).toEqual([]);
expect(findPlaceholders("#~#~")).toEqual([]);
});