No-op template

This commit is contained in:
aet
2021-07-21 21:26:22 -04:00
commit 2c504997af
7 changed files with 1462 additions and 0 deletions

34
test/index.ts Normal file
View File

@ -0,0 +1,34 @@
import { describe, it } from "mocha";
import { expect } from "chai";
import { transform } from "@babel/core";
import { format } from "prettier";
import plugin from "../src/index";
const javascript = (code: TemplateStringsArray) =>
transform(code[0], {
parserOpts: {
plugins: ["decorators-legacy", "typescript"],
},
plugins: [plugin],
})!.code!;
const canonize = (code: string) => format(code, { parser: "babel" }).trim();
const equal = (actual: string, expected: string) => {
actual = canonize(actual);
expected = canonize(expected);
expect(actual).to.deep.equal(expected);
};
describe("", () => {
it("should do nothing", () => {
equal(
javascript`
class A {}
`,
/* javascript */ `
class A {}
`
);
});
});