prettier-plugin-askama-temp.../test/printer.test.ts

35 lines
918 B
TypeScript
Raw Normal View History

2022-11-18 22:05:06 +03:00
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([
[0, 4],
[5, 10],
]);
expect(findPlaceholders("#~1~#X#~99~#")).toEqual([
[0, 4],
[6, 11],
]);
expect(findPlaceholders("#~1~##~X#~99~#")).toEqual([
[0, 4],
[5, 13],
[8, 13],
]);
expect(findPlaceholders("#~1~##~99~#~#")).toEqual([
[0, 4],
[5, 10],
]);
});
test("findPlaceholders should find no placeholders", () => {
expect(findPlaceholders("")).toEqual([]);
expect(findPlaceholders("#~#")).toEqual([]);
expect(findPlaceholders("#~ #")).toEqual([]);
expect(findPlaceholders("# ~#")).toEqual([]);
expect(findPlaceholders("#~#~")).toEqual([]);
});