Skip to content

Commit

Permalink
Move tests to @babel/standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 1, 2020
1 parent 7a3c8e9 commit 7b861ff
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions packages/babel-preset-env/test/preset-env.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// build-babel-standalone in CI coverage tests is skipped, so we skip this test as well
describe("preset-env", () => {
const Babel = require("../babel");

it("works w/o targets", () => {
const output = Babel.transform("const a = 1;", {
sourceType: "script",
presets: ["env"],
}).code;
expect(output).toBe("var a = 1;");
});

it("doesn't transpile `const` with chrome 60", () => {
const output = Babel.transform("const a = 1;", {
sourceType: "script",
presets: [
[
"env",
{
targets: {
chrome: 60,
},
},
],
],
}).code;
expect(output).toBe("const a = 1;");
});

it("transpiles `const` with chrome 60 and preset-es2015", () => {
const output = Babel.transform("const a = 1;", {
sourceType: "script",
presets: [
[
"env",
{
targets: {
chrome: 60,
},
},
],
"es2015",
],
}).code;
expect(output).toBe("var a = 1;");
});

it("uses transform-new-targets plugin", () => {
const output = Babel.transform("function Foo() {new.target}", {
sourceType: "script",
presets: ["env"],
}).code;
expect(output).toBe(
"function Foo() {\n this instanceof Foo ? this.constructor : void 0;\n}",
);
});
});

0 comments on commit 7b861ff

Please sign in to comment.