Migrate a few packages' tests to use Jest Expect (see below)

* 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
This commit is contained in:
Deven Bansod
2018-03-24 13:38:11 +05:30
parent 21309cc8d4
commit 8b57a3e3b9
33 changed files with 596 additions and 848 deletions

View File

@@ -1,4 +1,3 @@
const assert = require("assert");
const babel = require("@babel/core");
test("Doesn't use the same object for two different nodes in the AST", function() {
@@ -9,26 +8,20 @@ test("Doesn't use the same object for two different nodes in the AST", function(
plugins: [[require("../"), { loose: true }]],
}).ast;
assert.equal(ast.program.body[0].declarations[0].id.type, "Identifier");
assert.equal(ast.program.body[2].expression.type, "MemberExpression");
assert.equal(ast.program.body[2].expression.object.type, "Identifier");
assert.equal(ast.program.body[3].expression.type, "MemberExpression");
assert.equal(ast.program.body[3].expression.object.type, "Identifier");
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");
assert.notStrictEqual(
ast.program.body[2].expression.object,
expect(ast.program.body[2].expression.object).not.toBe(
ast.program.body[3].expression.object,
"Expected different nodes in the AST to not be the same object (one)",
);
assert.notStrictEqual(
ast.program.body[0].declarations[0].id,
expect(ast.program.body[0].declarations[0].id).not.toBe(
ast.program.body[3].expression.object,
"Expected different nodes in the AST to not be the same object (two)",
);
assert.notStrictEqual(
ast.program.body[0].declarations[0].id,
expect(ast.program.body[0].declarations[0].id).not.toBe(
ast.program.body[2].expression.object,
"Expected different nodes in the AST to not be the same object (three)",
);
});

View File

@@ -1,4 +1,3 @@
const assert = require("assert");
const babel = require("@babel/core");
const vm = require("vm");
@@ -27,9 +26,5 @@ test("Re-export doesn't overwrite __esModule flag", function() {
vm.runInNewContext(code, context);
// exports.__esModule shouldn't be overwritten.
assert.equal(
context.exports.__esModule,
true,
"Expected exports.__esModule === true",
);
expect(context.exports.__esModule).toBe(true);
});