| 1 |
import * as t from "../lib/index.js"; |
| 2 |
import * as vm from "vm"; |
| 3 |
|
| 4 |
describe("regressions", () => { |
| 5 |
const babel7 = process.env.BABEL_TYPES_8_BREAKING ? it.skip : it; |
| 6 |
|
| 7 |
babel7("jest .toMatchInlineSnapshot used 'Line' for comments", () => { |
| 8 |
expect(() => { |
| 9 |
t.file(t.program([]), [{ type: "Line" }]); |
| 10 |
}).not.toThrow(); |
| 11 |
}); |
| 12 |
|
| 13 |
it(".valueToNode works with objects from different contexts", () => { |
| 14 |
const context = {}; |
| 15 |
const script = new vm.Script(`this.obj = { foo: 2 }`); |
| 16 |
script.runInNewContext(context); |
| 17 |
|
| 18 |
expect(t.valueToNode(context.obj)).toMatchObject({ |
| 19 |
properties: [ |
| 20 |
{ |
| 21 |
computed: false, |
| 22 |
key: { name: "foo", type: "Identifier" }, |
| 23 |
shorthand: false, |
| 24 |
type: "ObjectProperty", |
| 25 |
value: { type: "NumericLiteral", value: 2 }, |
| 26 |
}, |
| 27 |
], |
| 28 |
type: "ObjectExpression", |
| 29 |
}); |
| 30 |
}); |
| 31 |
}); |