1
我找到了一個如何使用Sinon創建假服務器的示例。
以下是代碼(1),(2)。如何將僞造的服務器從Sinon轉換爲Jasmine。
只用Jasmine就可以做出同樣的事情嗎?
如果是。我應該如何重寫代碼(1)和(2)?
(1)
beforeEach(function() {
this.server = sinon.fakeServer.create();
this.server.respondWith(
'GET',
Routing.generate('api_get_url') + '/' + this.model.get('id'),
JSON.stringify(this.fixtureResponse)
);
});
(2)
it('should the response not change', function() {
this.model.fetch();
this.server.respond();
expect(this.fixtureResponse).toEqual(this.model.attributes);
});