swc/node-swc/__tests__/transform/hidden_jest.js

48 lines
960 B
JavaScript
Raw Normal View History

2020-09-18 08:29:50 +03:00
const swc = require("../../../");
it("should hoist methods", () => {
const src = 'console.log("Hello"); jest.mock(); console.log("World")';
expect(
swc.transformSync(src, {
jsc: {
transform: {
hidden: {
jest: true
}
}
}
})
.code.trim()
).toBe(`jest.mock();
console.log(\"Hello\");
console.log(\"World\");`);
});
2020-09-24 13:49:12 +03:00
it("should preserve calls", () => {
const src = `class Foo {
method() {
super.foo()
}
}`;
expect(
swc.transformSync(src, {
jsc: {
transform: {
hidden: {
jest: true
}
},
target: 'es2019'
}
})
.code.trim()
).toBe(`class Foo {
method() {
super.foo();
}
}`);
});