-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec5de3d
commit 23514d8
Showing
9 changed files
with
233 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<script> | ||
/** | ||
* The import comment. | ||
*/ | ||
import x from "./importable.js"; | ||
import X from "./importable.js"; | ||
</script> |
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,8 @@ | ||
<script> | ||
/** | ||
* The import comment. | ||
*/ | ||
import {y, z} from "./importable.js"; | ||
import X from "./importable.js"; | ||
</script> |
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,3 @@ | ||
export default x = 1; | ||
export let y = 1; | ||
export let z = 1; |
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,8 @@ | ||
<script> | ||
/** | ||
* The method comment. | ||
*/ | ||
function privateMethod(param1, param2) { | ||
return 0; | ||
}; | ||
</script> |
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,8 @@ | ||
<script> | ||
/** | ||
* The method comment. | ||
*/ | ||
export function publicMethod(param1, param2) { | ||
return 0; | ||
}; | ||
</script> |
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,62 @@ | ||
const path = require('path'); | ||
const chai = require('chai'); | ||
const expect = chai.expect; | ||
|
||
const parser = require('../../../../index'); | ||
|
||
describe('SvelteDoc v3 - Methods', () => { | ||
it('Private method should be parsed with comment and additional metadata', (done) => { | ||
parser.parse({ | ||
version: 3, | ||
filename: path.resolve(__dirname, 'method.private.svelte'), | ||
features: ['methods'], | ||
ignoredVisibilities: [] | ||
}).then((doc) => { | ||
expect(doc, 'Document should be provided').to.exist; | ||
expect(doc.methods, 'Document methods should be parsed').to.exist; | ||
|
||
expect(doc.methods.length).to.equal(1); | ||
const method = doc.methods[0]; | ||
expect(method.name).to.equal('privateMethod'); | ||
expect(method.visibility).to.equal('private'); | ||
expect(method.static).to.be.false; | ||
|
||
expect(method.args, 'Method arguments should be parsed').to.exist; | ||
expect(method.args.length).to.equal(2); | ||
expect(method.args[0].name).to.equal('param1'); | ||
expect(method.args[1].name).to.equal('param2'); | ||
|
||
expect(method.description).to.equal('The method comment.'); | ||
done(); | ||
}).catch(e => { | ||
done(e); | ||
}); | ||
}); | ||
|
||
it('Public method should be parsed with comment and additional metadata', (done) => { | ||
parser.parse({ | ||
version: 3, | ||
filename: path.resolve(__dirname, 'method.public.svelte'), | ||
features: ['methods'], | ||
ignoredVisibilities: [] | ||
}).then((doc) => { | ||
expect(doc, 'Document should be provided').to.exist; | ||
expect(doc.methods, 'Document methods should be parsed').to.exist; | ||
|
||
expect(doc.methods.length).to.equal(1); | ||
const method = doc.methods[0]; | ||
expect(method.name).to.equal('publicMethod'); | ||
expect(method.visibility).to.equal('public'); | ||
expect(method.static).to.be.false; | ||
|
||
expect(method.args, 'Method arguments should be parsed').to.exist; | ||
expect(method.args.length).to.equal(2); | ||
expect(method.args[0].name).to.equal('param1'); | ||
expect(method.args[1].name).to.equal('param2'); | ||
|
||
done(); | ||
}).catch(e => { | ||
done(e); | ||
}); | ||
}); | ||
}); |
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