Giter Site home page Giter Site logo

ionic-team / cap-plugin-mock-jasmine Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 751 KB

Show how to mock a Capacitor plugin in a Jasmine based unit test

Shell 0.34% TypeScript 49.12% JavaScript 6.47% HTML 5.32% SCSS 23.22% Java 3.53% Swift 9.48% Ruby 2.51%

cap-plugin-mock-jasmine's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cap-plugin-mock-jasmine's Issues

How to Unit Test App.addListener in Jasmine

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.