Does anyone know how to do a basic unit test with angular 2 to test the element of adding a basic Firebase base.
I use typescript instead of basic JavaScript for my code
This is what I am testing:
export class AppComponent { ref: Firebase; refUsers: Firebase; refProfiles: Firebase; constructor(){ this.ref = new Firebase("https://markng2.firebaseio.com"); this.refUsers = new Firebase("https://markng2.firebaseio.com/users"); this.refProfiles = new Firebase("https://markng2.firebaseio.com/profiles"); } public addUser(newUser: Object): void{ this.refUsers.push(newUser, ()=>{ }); } }
This is my current test:
import {it, iit, describe, expect, inject, injectAsync, beforeEachProviders, fakeAsync, tick } from 'angular2/testing'; import { AppComponent } from '../app/app'; describe('AppComponent', () => { it('saves an item to Firebase', () => { let refUsers = new Firebase(''); let service = new AppComponent(); spyOn(service.refUsers, 'push'); service.addUser({ item: true }); expect(service.refUsers.push).toHaveBeenCalled(); }) });
This is the error I get when doing this test:

source share