3
您好我正在使用fetch測試一個集合,當我打電話時,只有在調用server.response之後沒有來自假服務器的應答,我得到了所需的結果。Sinon假服務器不自動響應
這是爲什麼?
我的代碼
beforeEach(function() {
server = sinon.fakeServer.create();
server.autoRespond = true;
colhedoraList = new ColhedoraList();
});
.
.
.
var spy = sinon.spy(colhedoraList, 'parse');
server.respondWith("GET", "getColhedoraInfo",
[200, {"Content-Type": "application/json"},
'[{"id":"1","talhaoAtual":1,"posicionamentos":[{"lat":-23.9317401,"lng":-50.2210379,"elevadorLigado":true,"horario":"2012-09-21T11:27:58Z"},{"lat":-23.931544,"lng":-50.2161884,"elevadorLigado":true,"horario":"2012-09-21T11:28:02Z"}]}]']);
colhedoraList.fetch({add: true});
server.respond();
expect(spy).toHaveBeenCalled();
expect(spygmaps).toHaveBeenCalledTwice();
expect(colhedoraList.get(1).get('talhaoAtual')).toEqual(1); <<< ALL EXPECTS FAIL, If I don't call respond().
這是在文檔中? –
不,我只是通過閱讀實際的詩歌來源才發現它。您可能會在他們的GitHub上提交問題,要求他們更新文檔。 –