Skip to content

Commit

Permalink
Jest test updates (#75)
Browse files Browse the repository at this point in the history
* Update jest, add test updates from babel/babel

* update to eslint 3.x and use ^

* move top level dep to devDeps, make lodash a dependency

* remove babel-cli, using gulp-babel
  • Loading branch information
hzoo authored and kangax committed Aug 2, 2016
1 parent 5ee6e67 commit d4ff6f8
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 12 deletions.
17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,30 @@
"jest": {
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
"testEnvironment": "node",
"testPathPattern": [
"src"
"testPathDirs": [
"packages"
],
"preprocessorIgnorePatterns": [
"<rootDir>/node_modules/"
]
},
"dependencies": {
"babel-core": "^6.4.5",
"babel-traverse": "^6.3.26",
"lodash": "^4.13.1"
},
"devDependencies": {
"babel-cli": "^6.4.0",
"babel-jest": "^10.0.2",
"babel-core": "^6.4.5",
"babel-jest": "^14.1.0",
"babel-plugin-transform-es2015-block-scoping": "^6.10.1",
"babel-preset-es2015": "^6.3.13",
"babel-traverse": "^6.10.4",
"bytes": "^2.1.0",
"chalk": "^1.1.3",
"cli-table": "^0.3.1",
"closure-compiler": "^0.2.12",
"eslint": "^2.7.0",
"eslint": "~3.0.0",
"eslint-config-babel": "^1.0.0",
"gulp": "gulpjs/gulp#4.0",
"gulp-babel": "^6.1.2",
"gulp-newer": "^1.1.0",
"gulp-util": "^3.0.7",
"jest-cli": "^12.1.1",
"jest-cli": "^14.1.0",
"lerna": "2.0.0-beta.24",
"through2": "^2.0.1",
"uglify-js": "^2.6.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"babel-plugin"
],
"dependencies": {
"babel-helper-remove-or-void": "^0.0.0"
"babel-helper-remove-or-void": "^0.0.0",
"lodash": "^4.14.1"
},
"devDependencies": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,25 @@ describe("remove-console-plugin", () => {
`);
expect(transform(source).trim()).toBe(expected);
});

it("statement no block", () => {
const source = unpad(`
if (blah) console.log(blah);
for (;;) console.log(blah);
for (var blah in []) console.log(blah);
for (var blah of []) console.log(blah);
while (blah) console.log(blah);
do console.log(blah); while (blah);
`);

const expected = unpad(`
if (blah) {}
for (;;) {}
for (var blah in []) {}
for (var blah of []) {}
while (blah) {}
do {} while (blah);
`);
expect(transform(source).trim()).toBe(expected);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ jest.autoMockOff();

const babel = require("babel-core");
const plugin = require("../src/index");
const unpad = require("../../../utils/unpad");

function transform(code) {
return babel.transform(code, {
Expand All @@ -21,4 +22,25 @@ describe("remove-debugger-plugin", () => {
const expected = "1;";
expect(transform(source)).toBe(expected);
});

it("statement no block", () => {
const source = unpad(`
if (blah) debugger;
for (;;) debugger;
for (var blah in []) debugger;
for (var blah of []) debugger;
while (blah) debugger;
do debugger; while (blah);
`);

const expected = unpad(`
if (blah) {}
for (;;) {}
for (var blah in []) {}
for (var blah of []) {}
while (blah) {}
do {} while (blah);
`);
expect(transform(source).trim()).toBe(expected);
});
});

0 comments on commit d4ff6f8

Please sign in to comment.