我有一個構造器和一些類的類:如何用茉莉花測試功能?
import {Weight} from './weight';
export class Weight {
constructor(public viewCtrl: ViewController, public navCtrl: NavController, private user: User, private zone: NgZone, private alert: AlertPopupServices){
}
getSomeValue(a,b){
return a + b;
}
}
我想用茉莉花來測試它。
describe('BLABLABLA',() => {
TestBed.configureTestingModule({
declarations: [MyApp, Weight],
providers: [
SecureStorageServices, NavController, User, AlertPopupServices,
{provide: ViewController, useClass: ViewControllerMock},
],
imports: [
IonicModule.forRoot(MyApp), TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [Http]
}
})
]
}).compileComponents();
it('has to give the addition of two numbers',() => {
expect("FUNCTION CALL").toEqual(10);
});
});
但是我怎樣才能調用我的函數,並得到返回值?
感謝
你導入類權重在你的測試中? –
是的,我這樣做 – anubis