Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: #665 - Getting descendants where jsx was used in a non-jsx file …
…would throw an error.
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect } from "chai"; | ||
import { Project } from "../../Project"; | ||
|
||
describe("tests for issue #665", () => { | ||
it("should not error when getting the descendants when there's jsx in a ts file", () => { | ||
const project = new Project({ useVirtualFileSystem: true }); | ||
const file = project.createSourceFile("test.ts", ` | ||
function oi(){ | ||
const snapshot = { isDraggingOver: false }; | ||
function getSourceStyle(opts) { | ||
return {}; | ||
} | ||
return <div> | ||
<div></div> | ||
<p style={getSourceStyle(snapshot.isDraggingOver)}></p> | ||
</div> | ||
} | ||
`); | ||
|
||
expect(() => file.getDescendants()).to.not.throw(); | ||
}); | ||
|
||
it("should not error when getting the descendants when there's jsx in a ts file for second example", () => { | ||
const project = new Project({ useVirtualFileSystem: true }); | ||
const file = project.createSourceFile("test.ts", ` | ||
import * as React from 'react'; | ||
export const Broken: React.SFC<{ arg: boolean }> = (props) => ( | ||
<div style={getStyle(props.arg)} >...</div> | ||
) | ||
`); | ||
|
||
expect(() => file.getDescendants()).to.not.throw(); | ||
}); | ||
}); |