From 74228f1fb36adad3b5c109f99cd4d3f24f093f90 Mon Sep 17 00:00:00 2001 From: davidodenwald Date: Sun, 19 Mar 2023 18:02:41 +0100 Subject: [PATCH] add locStart and locEnd tests --- test/plugin.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/plugin.test.ts b/test/plugin.test.ts index 99d954d..3831bb3 100644 --- a/test/plugin.test.ts +++ b/test/plugin.test.ts @@ -1,6 +1,6 @@ import { existsSync, readdirSync, readFileSync } from "fs"; import { join } from "path"; -import { format, Options } from "prettier"; +import { format, Options, ParserOptions } from "prettier"; import * as jinjaPlugin from "../src/index"; 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(`

{{ test }}

`, {}, {} as ParserOptions); + const node = Object.values(ast.nodes)[0]!; + + expect(plugin.locStart(node)).toEqual(3); + expect(plugin.locEnd(node)).toEqual(13); +});