Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest test updates #75

Merged
merged 4 commits into from
Aug 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new test?

Copy link
Member Author

@hzoo hzoo Aug 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it's from a pr to babel (since I moved the plugin to this repo) babel/babel#3583

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);
});
});