Skip to content

Commit

Permalink
chore: copy preset-env-standalone test
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Dec 9, 2019
1 parent 18a8782 commit 49da681
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions packages/babel-standalone/test/babel.js
Expand Up @@ -110,6 +110,61 @@
).toThrow(/Invalid plugin specified in Babel options: "lolfail"/);
});

describe("env preset", () => {
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}",
);
});
});

describe("custom plugins and presets", () => {
const lolizer = () => ({
visitor: {
Expand Down

0 comments on commit 49da681

Please sign in to comment.