有誰知道如何使用角度2來測試基本火力點添加項目的基本單元測試。使用角度2的火力點添加單元測試
我使用打字稿,而不是基本的JavaScript爲我的代碼
這是我的測試:
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,()=>{
});
}
}
這是我目前的測試:
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();
})
});
這是我運行測試時得到的錯誤:個
似乎像一個配置問題 – AngularM