prettier-plugin-jinja-template
Version:
Prettier plugin for formatting jinja templates.
36 lines (32 loc) • 957 B
text/typescript
import { expect, test } from "vitest";
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([]);
});