-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: #778 - Fixes error being thrown when inserting after a jsdoc and…
… the jsdoc is the last member or statement. Closes #778.
- Loading branch information
Showing
6 changed files
with
93 additions
and
8 deletions.
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
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
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,64 @@ | ||
import { expect } from "chai"; | ||
import { getInfoFromText } from "../compiler/testHelpers"; | ||
|
||
describe("tests for issue #654", () => { | ||
it("should add a new member where there exists a js doc comment before at the end of the class", () => { | ||
const { sourceFile } = getInfoFromText(` | ||
class Foo { | ||
/** | ||
* | ||
*/ | ||
}`); | ||
const classDec = sourceFile.getClassOrThrow("Foo"); | ||
classDec.addConstructor({}); | ||
expect(sourceFile.getFullText()).to.equal(` | ||
class Foo { | ||
/** | ||
* | ||
*/ | ||
constructor() { | ||
} | ||
}`); | ||
}); | ||
|
||
it("should add a new member where there exists multiple comments and js docs at the end of the class", () => { | ||
const { sourceFile } = getInfoFromText(` | ||
class Foo { | ||
// asdf | ||
/** test */ | ||
// test | ||
/** test */ | ||
}`); | ||
const classDec = sourceFile.getClassOrThrow("Foo"); | ||
classDec.addConstructor({}); | ||
expect(sourceFile.getFullText()).to.equal(` | ||
class Foo { | ||
// asdf | ||
/** test */ | ||
// test | ||
/** test */ | ||
constructor() { | ||
} | ||
}`); | ||
}); | ||
|
||
it("should add a new source file statement where there exists multiple comments and js docs before at the end of the file", () => { | ||
const { sourceFile } = getInfoFromText(` | ||
// asdf | ||
/** test */ | ||
// test | ||
/** test */ | ||
// test | ||
`); | ||
sourceFile.addFunction({ name: "test" }); | ||
expect(sourceFile.getFullText()).to.equal(` | ||
// asdf | ||
/** test */ | ||
// test | ||
/** test */ | ||
// test | ||
function test() { | ||
} | ||
`); | ||
}); | ||
}); |