swc/node-swc/__tests__/script_test.js
강동윤 3a372ad29a
Move node-swc into the repository (#789)
The commit will help

 - Better testing
 - Preventing regression like #785.
 - **Implementing spack** (It requires access to neon api because of the plugin system)
2020-05-22 20:36:39 +09:00

23 lines
605 B
JavaScript

const swc = require("../../");
it("should handle script", () => {
const script = swc.transformSync(`foo;`, { isModule: false });
expect(script.code.trim()).toBe(`foo;`);
});
it("should parse as script if required", () => {
const script = swc.parseSync(`foo;`, { isModule: false });
expect(script.type).toBe("Script");
const out = swc.printSync(script);
expect(out.code.trim()).toBe(`foo;`);
});
it("should parse as module if required", () => {
const m = swc.parseSync(`foo;`);
expect(m.type).toBe("Module");
const out = swc.printSync(m);
expect(out.code.trim()).toBe(`foo;`);
});