我有這家工廠名爲Songs
其獲取歌曲的API每一秒:
我想測試它,我想它顯示波紋管,但我想我是在錯誤的方式注入服務。當我嘗試運行測試時,它輸出錯誤:沒有未決請求刷新!。它就像不打電話。
describe('Songs', function(){
var httpStub, localService;
beforeEach(module('pearlJam'));
beforeEach(inject(function(_$httpBackend_, Songs){
httpStub = _$httpBackend_;
localService = Songs;
}));
it('lists all songs', function(){
var httpResponse = { data: [1]};
httpStub.whenGET('api/songs.json').respond(httpResponse);
var serviceResponse = localService.all;
httpStub.flush();
expect(serviceResponse).toBe([1]);
});
});
什麼是'流'?它不應該是'歌'嗎? –
是的,我打錯了。 –