| 1 | import * as babel from "@babel/core"; |
| 2 | import polyfillRegenerator from "../lib"; |
| 3 | |
| 4 | function transform(code, babelOpts, pluginOpts) { |
| 5 | return babel.transformSync(code, { |
| 6 | configFile: false, |
| 7 | ...babelOpts, |
| 8 | plugins: [[polyfillRegenerator, pluginOpts]], |
| 9 | }); |
| 10 | } |
| 11 | |
| 12 | describe("targets", () => { |
| 13 | it("is not supported", () => { |
| 14 | expect(() => |
| 15 | transform( |
| 16 | "code", |
| 17 | {}, |
| 18 | { |
| 19 | method: "usage-pure", |
| 20 | targets: { chrome: 50 }, |
| 21 | }, |
| 22 | ), |
| 23 | ).toThrow(/targets/); |
| 24 | }); |
| 25 | }); |
| 26 | |
| 27 | describe("top-level targets", () => { |
| 28 | it("is supported", () => { |
| 29 | expect(() => |
| 30 | transform( |
| 31 | "code", |
| 32 | { targets: { chrome: 50 } }, |
| 33 | { |
| 34 | method: "usage-pure", |
| 35 | }, |
| 36 | ), |
| 37 | ).not.toThrow(/targets/); |
| 38 | }); |
| 39 | }); |