Test updates for newer Sinon

This commit is contained in:
Dan Stillman 2019-05-25 07:28:28 -04:00
parent ca7217cff7
commit e8dd1f7824
5 changed files with 16 additions and 12 deletions

View file

@ -376,7 +376,11 @@ Zotero.HTTP = new function() {
}
}
for (var header in headers) {
xmlhttp.setRequestHeader(header, headers[header]);
// Convert numbers to string to make Sinon happy
let value = typeof headers[header] == 'number'
? headers[header].toString()
: headers[header]
xmlhttp.setRequestHeader(header, value);
}
// Set timeout

View file

@ -218,7 +218,7 @@ describe("Zotero.FeedItem", function () {
yield item.toggleRead(true);
assert.isTrue(item.save.called, "item was saved on toggle read");
item.save.reset();
item.save.resetHistory();
yield item.toggleRead(true);
assert.isFalse(item.save.called, "item was not saved on toggle read to same state");

View file

@ -100,7 +100,7 @@ describe("Zotero.FeedItems", function () {
});
afterEach(function* () {
save.reset();
save.resetHistory();
yield clearFeeds();
});

View file

@ -355,7 +355,7 @@ describe("Zotero.Integration", function () {
});
afterEach(function() {
setDocumentDataSpy.reset();
setDocumentDataSpy.resetHistory();
});
after(function() {
@ -385,7 +385,7 @@ describe("Zotero.Integration", function () {
} catch (e) {}
await initDoc(docID, {style});
displayDialogStub.resetHistory();
displayAlertStub.reset();
displayAlertStub.resetHistory();
});
after(function* () {
@ -559,7 +559,7 @@ describe("Zotero.Integration", function () {
assert.isTrue(getCiteprocBibliographySpy.calledOnce);
assert.equal(getCiteprocBibliographySpy.lastCall.returnValue[0].entry_ids.length, 3);
getCiteprocBibliographySpy.reset();
getCiteprocBibliographySpy.resetHistory();
setAddEditItems(testItems[3]);
yield execCommand('addEditCitation', docID);
@ -580,7 +580,7 @@ describe("Zotero.Integration", function () {
assert.isTrue(getCiteprocBibliographySpy.calledOnce);
assert.equal(getCiteprocBibliographySpy.lastCall.returnValue[0].entry_ids.length, 3);
getCiteprocBibliographySpy.reset();
getCiteprocBibliographySpy.resetHistory();
sinon.stub(doc, 'cursorInField').resolves(doc.fields[1]);
sinon.stub(doc, 'canInsertField').resolves(false);
@ -603,7 +603,7 @@ describe("Zotero.Integration", function () {
displayAlertStub = sinon.stub(DocumentPluginDummy.Document.prototype, 'displayAlert').resolves(0);
});
beforeEach(function() {
displayAlertStub.reset();
displayAlertStub.resetHistory();
});
after(function() {
displayAlertStub.restore();

View file

@ -147,7 +147,7 @@ describe("Zotero.ItemTreeView", function() {
assert.equal(selected[0], existingItemID);
// Reset call count on spy
win.ZoteroPane.itemSelected.reset();
win.ZoteroPane.itemSelected.resetHistory();
// Create item with skipNotifier flag
var item = new Zotero.Item('book');
@ -172,7 +172,7 @@ describe("Zotero.ItemTreeView", function() {
assert.equal(selected[0], existingItemID);
// Reset call count on spy
win.ZoteroPane.itemSelected.reset();
win.ZoteroPane.itemSelected.resetHistory();
// Create item with skipSelect flag
var item = new Zotero.Item('book');
@ -267,7 +267,7 @@ describe("Zotero.ItemTreeView", function() {
itemsView.selection.clearSelection();
assert.lengthOf(itemsView.getSelectedItems(), 0);
// Reset call count on spy
win.ZoteroPane.itemSelected.reset();
win.ZoteroPane.itemSelected.resetHistory();
// Modify item
item.setField('title', 'no select on modify');
@ -293,7 +293,7 @@ describe("Zotero.ItemTreeView", function() {
assert.equal(selected[0], id);
// Reset call count on spy
win.ZoteroPane.itemSelected.reset();
win.ZoteroPane.itemSelected.resetHistory();
// Modify item
item.setField('title', 'maintain selection on modify');