mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 15:12:08 +03:00
17 lines
488 B
JavaScript
17 lines
488 B
JavaScript
|
const swc = require("../../");
|
||
|
|
||
|
it("should detect script", () => {
|
||
|
const script = swc.parseSync(`const fs = require('fs');`, { isModule: "unknown" });
|
||
|
expect(script.type).toBe("Script");
|
||
|
});
|
||
|
|
||
|
it("should default to isModule: true", () => {
|
||
|
const script = swc.parseSync(`foo;`, {});
|
||
|
expect(script.type).toBe("Module");
|
||
|
});
|
||
|
|
||
|
it("should detect module", () => {
|
||
|
const script = swc.parseSync(`import fs from "fs";`, { isModule: "unknown" });
|
||
|
expect(script.type).toBe("Module");
|
||
|
});
|