[babel 8] Improve syntax highlighting (#12660)

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Simon Lydell <simon.lydell@gmail.com>
This commit is contained in:
Nicolò Ribaudo
2021-01-22 17:56:20 +01:00
committed by GitHub
parent 22eb99bea4
commit 6a961497aa
4 changed files with 218 additions and 42 deletions

View File

@@ -283,6 +283,36 @@ describe("@babel/code-frame", function () {
);
});
test("jsx", function () {
const gutter = chalk.grey;
const yellow = chalk.yellow;
const rawLines = ["<div />"].join("\n");
expect(
JSON.stringify(
codeFrame(rawLines, 0, null, {
linesAbove: 1,
linesBelow: 1,
forceColor: true,
}),
),
).toEqual(
JSON.stringify(
chalk.reset(
" " +
gutter(" 1 |") +
" " +
yellow("<") +
yellow("div") +
" " +
yellow("/") +
yellow(">"),
),
),
);
});
test("basic usage, new API", function () {
const rawLines = ["class Foo {", " constructor()", "};"].join("\n");
expect(