-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a3c8e9
commit 7b861ff
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}", | ||
); | ||
}); | ||
}); |