-
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
Showing
5 changed files
with
121 additions
and
5 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,5 @@ | ||
<ShopingCart bind:this={cart} /> | ||
|
||
<script> | ||
import ShopingCart from './ShopingCart.svelte'; | ||
</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,7 @@ | ||
<div bind:this={header}> | ||
Header | ||
</div> | ||
|
||
<script> | ||
let header; | ||
</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,3 @@ | ||
<div bind:this={header}> | ||
The header | ||
</div> |
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,79 @@ | ||
const path = require('path'); | ||
const chai = require('chai'); | ||
const expect = chai.expect; | ||
|
||
const parser = require('../../../../index'); | ||
|
||
describe('SvelteDoc v3 - Refs', () => { | ||
it('Ref to non declared variable', (done) => { | ||
parser.parse({ | ||
version: 3, | ||
filename: path.resolve(__dirname, 'ref.simple.svelte'), | ||
features: ['refs'], | ||
ignoredVisibilities: [] | ||
}).then((doc) => { | ||
expect(doc, 'Document should be provided').to.exist; | ||
expect(doc.refs, 'Document refs should be parsed').to.exist; | ||
|
||
expect(doc.refs.length).to.equal(1); | ||
const ref = doc.refs[0]; | ||
|
||
expect(ref, 'Ref should be a valid entity').to.exist; | ||
expect(ref.name).to.equal('header'); | ||
expect(ref.parent).to.equal('div'); | ||
expect(ref.visibility).to.equal('private'); | ||
|
||
done(); | ||
}).catch(e => { | ||
done(e); | ||
}); | ||
}); | ||
|
||
it('Ref to declared variable', (done) => { | ||
parser.parse({ | ||
version: 3, | ||
filename: path.resolve(__dirname, 'ref.declared.svelte'), | ||
features: ['refs'], | ||
ignoredVisibilities: [] | ||
}).then((doc) => { | ||
expect(doc, 'Document should be provided').to.exist; | ||
expect(doc.refs, 'Document refs should be parsed').to.exist; | ||
|
||
expect(doc.refs.length).to.equal(1); | ||
const ref = doc.refs[0]; | ||
|
||
expect(ref, 'Ref should be a valid entity').to.exist; | ||
expect(ref.name).to.equal('header'); | ||
expect(ref.parent).to.equal('div'); | ||
expect(ref.visibility).to.equal('private'); | ||
|
||
done(); | ||
}).catch(e => { | ||
done(e); | ||
}); | ||
}); | ||
|
||
it('Ref to component', (done) => { | ||
parser.parse({ | ||
version: 3, | ||
filename: path.resolve(__dirname, 'ref.component.svelte'), | ||
features: ['refs'], | ||
ignoredVisibilities: [] | ||
}).then((doc) => { | ||
expect(doc, 'Document should be provided').to.exist; | ||
expect(doc.refs, 'Document refs should be parsed').to.exist; | ||
|
||
expect(doc.refs.length).to.equal(1); | ||
const ref = doc.refs[0]; | ||
|
||
expect(ref, 'Ref should be a valid entity').to.exist; | ||
expect(ref.name).to.equal('cart'); | ||
expect(ref.parent).to.equal('ShopingCart'); | ||
expect(ref.visibility).to.equal('private'); | ||
|
||
done(); | ||
}).catch(e => { | ||
done(e); | ||
}); | ||
}); | ||
}); |