2015-04-14 64 views

回答

1

你可以在任何你想要的間諜,在茉莉的測試只是確保你得到的服務:

var thisSvc, thatSvc; 

beforeEach(inject(function(_thisSvc_, _thatSvc_){ 
    thisSvc = _thisSvc_; 
    thatSvc = _thatSvc_; 
}); 

it('.asyncOperation should call thatSvc.getById', function(){ 
    spyOn(thatSvc, 'getById'); 
    var id = 4; 

    thisSvc.asyncOperation(id); 

    expect(thatSvc.getById).toHaveBeenCalledWith(id); 
}) 
相關問題