* Migrate the following packages' tests:
* babel-helper-annotate-as-pure
* babel-helper-module-imports
* babel-helper-transform-fixture-test-runner
* babel-highlight
* babel-node
* babel-plugin-transform-modules-commonjs
* babel-preset-env-standalone
* babel-preset-env
* babel-preset-es2015
* babel-preset-react
* babel-standalone
* babel-template
* babel-traverse
* babel-types
28 lines
979 B
JavaScript
28 lines
979 B
JavaScript
const babel = require("@babel/core");
|
|
|
|
test("Doesn't use the same object for two different nodes in the AST", function() {
|
|
const code = 'import Foo from "bar"; Foo; Foo;';
|
|
|
|
const ast = babel.transform(code, {
|
|
ast: true,
|
|
plugins: [[require("../"), { loose: true }]],
|
|
}).ast;
|
|
|
|
expect(ast.program.body[0].declarations[0].id.type).toBe("Identifier");
|
|
expect(ast.program.body[2].expression.type).toBe("MemberExpression");
|
|
expect(ast.program.body[2].expression.object.type).toBe("Identifier");
|
|
expect(ast.program.body[3].expression.type).toBe("MemberExpression");
|
|
expect(ast.program.body[3].expression.object.type).toBe("Identifier");
|
|
|
|
expect(ast.program.body[2].expression.object).not.toBe(
|
|
ast.program.body[3].expression.object,
|
|
);
|
|
|
|
expect(ast.program.body[0].declarations[0].id).not.toBe(
|
|
ast.program.body[3].expression.object,
|
|
);
|
|
expect(ast.program.body[0].declarations[0].id).not.toBe(
|
|
ast.program.body[2].expression.object,
|
|
);
|
|
});
|