ionic-team / ionic-team/cap-plugin-mock-jasmine
How to Unit Test App.addListener in Jasmine
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I am trying to write Jasmine unit tests for events passed from App.
Here is my code .ts file:
` public _disableBackButton(): void {
App.addListener('backButton', () => {
return;
});
}`
Here is .spec file:
it('should disable back button', fakeAsync(() => {
spyOn(App, 'addListener').and.callFake((type: string, fn: BackButtonListener) => {
return { type, fn };
});
component._disableBackButton();
App.addListener('backButton', () => ({}));
expect(App.addListener).toBeDefined();
}));
But it can't run into callFake.
The docs on testing seem limited, and I cannot see any issues on this. Am I missing a simple thing?
Thanks in advance!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.