有谁知道如何使用角度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