jeudi 3 décembre 2015

How do you mock Firebase using Mockfirebase for Angular2 Unit Tests?

How do you mock firebase using mockfirebase for firebase unit tests?

I'm current using this link from firebase, but it uses require and I need to import the mockfirebase in from my node modules.

Here's one of my tests I would like to change to mockfirebase:

 import { it, iit, describe, expect, inject, injectAsync, beforeEachProviders, fakeAsync, tick } from 'angular2/testing';
 import { FirebaseService } from '../app/firebase-service';

 describe('Firebase Service Calls', () => {

      it('log out user from Firebase', () => {
          let ref = new Firebase("http://ift.tt/1XHbmns");
          let service = new FirebaseService();

          spyOn(service.ref, 'unauth');
          service.logOut();

          expect(service.ref.unauth).toHaveBeenCalled();
      })

 });

I want to change this line: "let ref = new Firebase("http://ift.tt/1XHbmns");"

I've also been looking at this link but they use require instead of import for using it: http://ift.tt/18wkPLy

Thank you.

Aucun commentaire:

Enregistrer un commentaire