mirror of
https://github.com/swc-project/swc.git
synced 2024-12-22 05:01:42 +03:00
3a372ad29a
The commit will help - Better testing - Preventing regression like #785. - **Implementing spack** (It requires access to neon api because of the plugin system)
32 lines
871 B
JavaScript
32 lines
871 B
JavaScript
const swc = require("../../../");
|
|
|
|
it("should work asynchronously", async () => {
|
|
const m = await swc.parse(`class Foo {}`);
|
|
|
|
expect(m.type).toBe(`Module`);
|
|
expect(m.body).toHaveLength(1);
|
|
expect(m.body[0].type).toBe(`ClassDeclaration`);
|
|
});
|
|
|
|
it("can work synchronously", () => {
|
|
const m = swc.parseSync(`class Foo {}`);
|
|
|
|
expect(m.type).toBe(`Module`);
|
|
expect(m.body).toHaveLength(1);
|
|
expect(m.body[0].type).toBe(`ClassDeclaration`);
|
|
});
|
|
|
|
it("can be emit code back asynchronously", async () => {
|
|
const m = await swc.parse(`class Foo {}`);
|
|
const out = await swc.print(m);
|
|
|
|
expect(out.code.trim().replace("\n", "")).toBe(`class Foo {}`);
|
|
});
|
|
|
|
it("can be emit code back synchronously", async () => {
|
|
const m = await swc.parseSync(`class Foo {}`);
|
|
const out = swc.printSync(m);
|
|
|
|
expect(out.code.trim().replace("\n", "")).toBe(`class Foo {}`);
|
|
});
|