add locStart and locEnd tests

This commit is contained in:
davidodenwald 2023-03-19 18:02:41 +01:00
parent f154303f76
commit 74228f1fb3

View file

@ -1,6 +1,6 @@
import { existsSync, readdirSync, readFileSync } from "fs"; import { existsSync, readdirSync, readFileSync } from "fs";
import { join } from "path"; import { join } from "path";
import { format, Options } from "prettier"; import { format, Options, ParserOptions } from "prettier";
import * as jinjaPlugin from "../src/index"; import * as jinjaPlugin from "../src/index";
const prettify = (code: string, options: Options) => const prettify = (code: string, options: Options) =>
@ -42,3 +42,13 @@ tests.forEach((test) => {
} }
}); });
}); });
test("node has correct locStart and -End", () => {
const plugin = jinjaPlugin.parsers["jinja-template"];
const ast = plugin.parse(`<p>{{ test }}</p>`, {}, {} as ParserOptions);
const node = Object.values(ast.nodes)[0]!;
expect(plugin.locStart(node)).toEqual(3);
expect(plugin.locEnd(node)).toEqual(13);
});