Skip to content

Commit

Permalink
Change usage of "suite"/"test" in unit-tests to "describe"/"it" (babe…
Browse files Browse the repository at this point in the history
  • Loading branch information
DrewML authored and panagosg7 committed Jan 17, 2017
1 parent 5d12f0d commit bd0be50
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 145 deletions.
4 changes: 2 additions & 2 deletions packages/babel-cli/test/index.js
Expand Up @@ -139,7 +139,7 @@ _.each(fs.readdirSync(fixtureLoc), function (binName) {
if (binName[0] === ".") return;

let suiteLoc = path.join(fixtureLoc, binName);
suite("bin/" + binName, function () {
describe("bin/" + binName, function () {
_.each(fs.readdirSync(suiteLoc), function (testName) {
if (testName[0] === ".") return;

Expand Down Expand Up @@ -170,7 +170,7 @@ _.each(fs.readdirSync(fixtureLoc), function (binName) {
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
}

test(testName, buildTest(binName, testName, opts));
it(testName, buildTest(binName, testName, opts));
});
});
});
22 changes: 11 additions & 11 deletions packages/babel-code-frame/test/index.js
Expand Up @@ -2,8 +2,8 @@ let assert = require("assert");
let chalk = require("chalk");
let codeFrame = require("..");

suite("babel-code-frame", function () {
test("basic usage", function () {
describe("babel-code-frame", function () {
it("basic usage", function () {
const rawLines = [
"class Foo {",
" constructor()",
Expand All @@ -17,7 +17,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("optional column number", function () {
it("optional column number", function () {
const rawLines = [
"class Foo {",
" constructor()",
Expand All @@ -30,7 +30,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("optional column number", function () {
it("optional column number", function () {
const rawLines = [
"class Foo {",
" constructor()",
Expand All @@ -43,7 +43,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("maximum context lines and padding", function () {
it("maximum context lines and padding", function () {
const rawLines = [
"/**",
" * Sums two numbers.",
Expand All @@ -68,7 +68,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("no unnecessary padding due to one-off errors", function () {
it("no unnecessary padding due to one-off errors", function () {
const rawLines = [
"/**",
" * Sums two numbers.",
Expand All @@ -93,7 +93,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("tabs", function () {
it("tabs", function () {
const rawLines = [
"\tclass Foo {",
"\t \t\t constructor\t(\t)",
Expand All @@ -107,7 +107,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("opts.highlightCode", function () {
it("opts.highlightCode", function () {
const rawLines = "console.log('babel')";
const result = codeFrame(rawLines, 1, 9, {highlightCode: true});
const stripped = chalk.stripColor(result);
Expand All @@ -118,7 +118,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("opts.linesAbove", function () {
it("opts.linesAbove", function () {
let rawLines = [
"/**",
" * Sums two numbers.",
Expand All @@ -142,7 +142,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("opts.linesBelow", function () {
it("opts.linesBelow", function () {
let rawLines = [
"/**",
" * Sums two numbers.",
Expand All @@ -165,7 +165,7 @@ suite("babel-code-frame", function () {
].join("\n"));
});

test("opts.linesAbove and opts.linesBelow", function () {
it("opts.linesAbove and opts.linesBelow", function () {
let rawLines = [
"/**",
" * Sums two numbers.",
Expand Down
62 changes: 31 additions & 31 deletions packages/babel-core/test/api.js
Expand Up @@ -22,7 +22,7 @@ function transformAsync(code, opts) {
};
}

suite("parser and generator options", function() {
describe("parser and generator options", function() {
let recast = {
parse: function(code, opts) {
return opts.parser.parse(code);
Expand All @@ -45,13 +45,13 @@ suite("parser and generator options", function() {
});
}

test("options", function() {
it("options", function() {
let string = "original;";
assert.deepEqual(newTransform(string).ast, babel.transform(string).ast);
assert.equal(newTransform(string).code, string);
});

test("experimental syntax", function() {
it("experimental syntax", function() {
let experimental = "var a: number = 1;";

assert.deepEqual(newTransform(experimental).ast, babel.transform(experimental, {
Expand Down Expand Up @@ -81,7 +81,7 @@ suite("parser and generator options", function() {
assert.equal(newTransformWithPlugins(experimental).code, experimental);
});

test("other options", function() {
it("other options", function() {
let experimental = "if (true) {\n import a from 'a';\n}";

assert.notEqual(newTransform(experimental).ast, babel.transform(experimental, {
Expand All @@ -93,8 +93,8 @@ suite("parser and generator options", function() {
});
});

suite("api", function () {
test("analyze", function () {
describe("api", function () {
it("analyze", function () {
assert.equal(babel.analyse("foobar;").marked.length, 0);

assert.equal(babel.analyse("foobar;", {
Expand All @@ -114,19 +114,19 @@ suite("api", function () {
}).marked[0].message, "foobar");
});

test("transformFile", function (done) {
it("transformFile", function (done) {
babel.transformFile(__dirname + "/fixtures/api/file.js", {}, function (err, res) {
if (err) return done(err);
assert.equal(res.code, "foo();");
done();
});
});

test("transformFileSync", function () {
it("transformFileSync", function () {
assert.equal(babel.transformFileSync(__dirname + "/fixtures/api/file.js", {}).code, "foo();");
});

test("options throw on falsy true", function () {
it("options throw on falsy true", function () {
return assert.throws(
function () {
babel.transform("", {
Expand All @@ -137,7 +137,7 @@ suite("api", function () {
);
});

test("options merge backwards", function () {
it("options merge backwards", function () {
return transformAsync("", {
presets: [__dirname + "/../../babel-preset-es2015"],
plugins: [__dirname + "/../../babel-plugin-syntax-jsx"]
Expand All @@ -146,7 +146,7 @@ suite("api", function () {
});
});

test("option wrapPluginVisitorMethod", function () {
it("option wrapPluginVisitorMethod", function () {
let calledRaw = 0;
let calledIntercept = 0;

Expand Down Expand Up @@ -178,7 +178,7 @@ suite("api", function () {
assert.equal(calledIntercept, 4);
});

test("pass per preset", function () {
it("pass per preset", function () {
let aliasBaseType = null;

function execTest(passPerPreset) {
Expand Down Expand Up @@ -255,7 +255,7 @@ suite("api", function () {

});

test("handles preset shortcuts (adds babel-preset-)", function () {
it("handles preset shortcuts (adds babel-preset-)", function () {
return assert.throws(
function () {
babel.transform("", {
Expand All @@ -266,7 +266,7 @@ suite("api", function () {
);
});

test("handles preset shortcuts 2 (adds babel-preset-)", function () {
it("handles preset shortcuts 2 (adds babel-preset-)", function () {
return assert.throws(
function () {
babel.transform("", {
Expand All @@ -277,7 +277,7 @@ suite("api", function () {
);
});

test("source map merging", function () {
it("source map merging", function () {
let result = babel.transform([
"function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }",
"",
Expand Down Expand Up @@ -315,19 +315,19 @@ suite("api", function () {
});
});

test("code option false", function () {
it("code option false", function () {
return transformAsync("foo('bar');", { code: false }).then(function (result) {
assert.ok(!result.code);
});
});

test("ast option false", function () {
it("ast option false", function () {
return transformAsync("foo('bar');", { ast: false }).then(function (result) {
assert.ok(!result.ast);
});
});

test("auxiliaryComment option", function () {
it("auxiliaryComment option", function () {
return transformAsync("class Foo {}", {
auxiliaryCommentBefore: "before",
auxiliaryCommentAfter: "after",
Expand All @@ -347,7 +347,7 @@ suite("api", function () {
});
});

test("modules metadata", function () {
it("modules metadata", function () {
return Promise.all([
transformAsync("import { externalName as localName } from \"external\";").then(function (result) {
assert.deepEqual(result.metadata.modules.imports[0], {
Expand Down Expand Up @@ -499,7 +499,7 @@ suite("api", function () {
]);
});

test("ignore option", function () {
it("ignore option", function () {
return Promise.all([
transformAsync("", {
ignore: "node_modules",
Expand All @@ -518,7 +518,7 @@ suite("api", function () {
]);
});

test("only option", function () {
it("only option", function () {
return Promise.all([
transformAsync("", {
only: "node_modules",
Expand Down Expand Up @@ -552,7 +552,7 @@ suite("api", function () {
]);
});

suite("env option", function () {
describe("env option", function () {
let oldBabelEnv = process.env.BABEL_ENV;
let oldNodeEnv = process.env.NODE_ENV;

Expand All @@ -568,7 +568,7 @@ suite("api", function () {
process.env.NODE_ENV = oldNodeEnv;
});

test("default", function () {
it("default", function () {
let result = babel.transform("foo;", {
env: {
development: { code: false }
Expand All @@ -578,7 +578,7 @@ suite("api", function () {
assert.equal(result.code, undefined);
});

test("BABEL_ENV", function () {
it("BABEL_ENV", function () {
process.env.BABEL_ENV = "foo";
let result = babel.transform("foo;", {
env: {
Expand All @@ -588,7 +588,7 @@ suite("api", function () {
assert.equal(result.code, undefined);
});

test("NODE_ENV", function () {
it("NODE_ENV", function () {
process.env.NODE_ENV = "foo";
let result = babel.transform("foo;", {
env: {
Expand All @@ -599,7 +599,7 @@ suite("api", function () {
});
});

test("resolveModuleSource option", function () {
it("resolveModuleSource option", function () {
let actual = "import foo from \"foo-import-default\";\nimport \"foo-import-bare\";\nexport { foo } from \"foo-export-named\";";
let expected = "import foo from \"resolved/foo-import-default\";\nimport \"resolved/foo-import-bare\";\nexport { foo } from \"resolved/foo-export-named\";";

Expand All @@ -612,26 +612,26 @@ suite("api", function () {
});
});

suite("buildExternalHelpers", function () {
test("all", function () {
describe("buildExternalHelpers", function () {
it("all", function () {
let script = buildExternalHelpers();
assert.ok(script.indexOf("classCallCheck") >= -1);
assert.ok(script.indexOf("inherits") >= 0);
});

test("whitelist", function () {
it("whitelist", function () {
let script = buildExternalHelpers(["inherits"]);
assert.ok(script.indexOf("classCallCheck") === -1);
assert.ok(script.indexOf("inherits") >= 0);
});

test("empty whitelist", function () {
it("empty whitelist", function () {
let script = buildExternalHelpers([]);
assert.ok(script.indexOf("classCallCheck") === -1);
assert.ok(script.indexOf("inherits") === -1);
});

test("underscored", function () {
it("underscored", function () {
let script = buildExternalHelpers(["typeof"]);
assert.ok(script.indexOf("typeof") >= 0);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/test/browserify.js
Expand Up @@ -3,8 +3,8 @@ let assert = require("assert");
let path = require("path");
let vm = require("vm");

suite("browserify", function() {
test("babel/register may be used without breaking browserify", function(done) {
describe("browserify", function() {
it("babel/register may be used without breaking browserify", function(done) {
let bundler = browserify(path.join(__dirname, "fixtures/browserify/register.js"));

bundler.bundle(function(err, bundle) {
Expand Down

0 comments on commit bd0be50

Please sign in to comment.