-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Add fix for other types of nodes in referencePaths #123
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
jest.autoMockOff(); | ||
|
||
const babel = require("babel-core"); | ||
const unpad = require("../../../utils/unpad"); | ||
|
||
function transform(code, options = {}, sourceType = "script") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would make sense to move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah.. Like discussed here #76 ... separate PR for all these things ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, I forgot :) If you can make a PR for that, I'd gladly merge — would make tests a bit cleaner. |
||
return babel.transform(code, { | ||
sourceType, | ||
minified: false, | ||
presets: [ | ||
require("../src/index") | ||
], | ||
}).code; | ||
} | ||
|
||
describe("preset", () => { | ||
// https://github.com/babel/babili/issues/122 | ||
it ("should fix issue#122", () => { | ||
const source = unpad(` | ||
function foo() { | ||
var a, b, c; | ||
if (a) { | ||
if (b) { | ||
if (c) {} | ||
} | ||
} else { | ||
if (b) { | ||
} else { | ||
if (c) {} | ||
} | ||
} | ||
} | ||
`); | ||
const expected = unpad(` | ||
function foo() { | ||
var d, e, f; | ||
d ? e && f : !b && f; | ||
} | ||
`); | ||
expect(transform(source)).toBe(expected); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should add this to DCE as well... or shall I add it to preset tests ?