35 lines
784 B
TypeScript
35 lines
784 B
TypeScript
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 {}
|
|
`
|
|
);
|
|
});
|
|
});
|