Skip to content

Commit

Permalink
Add tests to reproduce issue #32
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprey committed Aug 24, 2020
1 parent 1bcbbff commit 6c6867e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
import EventBus from 'eventbus';
const unsubscribe = EventBus.subscribe('income', (e) => {
dispatch('change');
});
</script>

<div>
Simple component
</div>

22 changes: 22 additions & 0 deletions test/svelte3/integration/events/events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,26 @@ describe('SvelteDoc v3 - Events', () => {
done(e);
});
});

it('Dispatch event from external callback', (done) => {
parser.parse({
version: 3,
filename: path.resolve(__dirname, 'event.dispatcher.externalCallback.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 === 'change');

expect(event, 'Event should be a valid entity').to.exist;
expect(event.name).to.equal('change');
expect(event.visibility).to.equal('public');

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

0 comments on commit 6c6867e

Please sign in to comment.