add locStart and locEnd tests
This commit is contained in:
parent
f154303f76
commit
74228f1fb3
1 changed files with 11 additions and 1 deletions
|
@ -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);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue