carto.js/test/spec/util/backbone-abort-sync.spec.js
2020-06-13 18:34:34 +08:00

18 lines
555 B
JavaScript

var Model = require('../../../src/core/model');
var BackboneAbortSync = require('../../../src/util/backbone-abort-sync');
describe('util/backbone-abort-sync', function () {
beforeEach(function () {
this.model = new Model();
this.model.url = 'url';
this.model.sync = BackboneAbortSync.bind(this.model);
});
it('should abort old ongoing request', function () {
var oldXHR = jasmine.createSpyObj('XHR', ['abort', 'always']);
this.model._xhr = oldXHR;
this.model.fetch();
expect(oldXHR.abort).toHaveBeenCalled();
});
});