Skip to content

Commit

Permalink
Add tests to cover issue #31
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprey committed Aug 24, 2020
1 parent 6c6867e commit 0f47b01
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
function handleClickEvent() {
console.log('Clickув');
}
</script>

<div>
<!-- Event fired when user clicked on button. -->
<button on:click="{() => handleClickEvent()}" on:click>
Click to fire
</button>
</div>
24 changes: 24 additions & 0 deletions test/svelte3/integration/events/events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@ describe('SvelteDoc v3 - Events', () => {
});
});

it('Propogated events in markup should be parsed even it was before handled', (done) => {
parser.parse({
version: 3,
filename: path.resolve(__dirname, 'event.markup.handleAndPropogate.svelte'),
features: ['events'],
ignoredVisibilities: []
}).then((doc) => {
expect(doc, 'Document should be provided').to.exist;
expect(doc.events, 'Document events should be parsed').to.exist;

const event = doc.events.find(e => e.name === 'click');

expect(event, 'Event should be a valid entity').to.exist;
expect(event.name).to.equal('click');
expect(event.visibility).to.equal('public');
expect(event.parent).to.be.equal('button');
expect(event.description).to.equal('Event fired when user clicked on button.');

done();
}).catch(e => {
done(e);
});
});

it('Dispatch event from code should be found', (done) => {
parser.parse({
version: 3,
Expand Down

0 comments on commit 0f47b01

Please sign in to comment.