0
我一直在試圖測試我正在寫的服務,它利用了角度數據數據存儲,讓它調用傳遞給then()
的回調。我已經有了一個基本的例子,說明了我想要做的以及我期望發生的事情。任何人都可以闡明我做錯了什麼,爲什麼這不能按預期工作?如何在使用角度數據模擬時調用DS.find()。then()
我希望這個測試通過並打印this is called
到控制檯。它既沒有,也沒有「預期錯誤是真實的」。我們的工作了
describe('usage of expectFind', function(){
beforeEach(function (done) {
inject(function (_DS_) {
DS = _DS_;
done();
});
});
it('should call the callback passed to then', function(done){
DS.expectFind('foo', 1).respond([{a: 'thing'}])
var called = false;
DS.find('foo', 1).then(function(aFoo){
console.log('this is called');
called = true;
done();
});
expect(called).toBe(true);
});
});
此外,我試圖用'angular-data-mocks'標籤添加它,但它不存在,我沒有足夠的代表來創建它,如果有人可以添加它,那將是很棒的。 – redrah 2015-01-26 18:30:57