Test updates for newer Sinon
This commit is contained in:
parent
ca7217cff7
commit
e8dd1f7824
5 changed files with 16 additions and 12 deletions
|
@ -376,7 +376,11 @@ Zotero.HTTP = new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var header in headers) {
|
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
|
// Set timeout
|
||||||
|
|
|
@ -218,7 +218,7 @@ describe("Zotero.FeedItem", function () {
|
||||||
yield item.toggleRead(true);
|
yield item.toggleRead(true);
|
||||||
assert.isTrue(item.save.called, "item was saved on toggle read");
|
assert.isTrue(item.save.called, "item was saved on toggle read");
|
||||||
|
|
||||||
item.save.reset();
|
item.save.resetHistory();
|
||||||
|
|
||||||
yield item.toggleRead(true);
|
yield item.toggleRead(true);
|
||||||
assert.isFalse(item.save.called, "item was not saved on toggle read to same state");
|
assert.isFalse(item.save.called, "item was not saved on toggle read to same state");
|
||||||
|
|
|
@ -100,7 +100,7 @@ describe("Zotero.FeedItems", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function* () {
|
afterEach(function* () {
|
||||||
save.reset();
|
save.resetHistory();
|
||||||
|
|
||||||
yield clearFeeds();
|
yield clearFeeds();
|
||||||
});
|
});
|
||||||
|
|
|
@ -355,7 +355,7 @@ describe("Zotero.Integration", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
setDocumentDataSpy.reset();
|
setDocumentDataSpy.resetHistory();
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
|
@ -385,7 +385,7 @@ describe("Zotero.Integration", function () {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
await initDoc(docID, {style});
|
await initDoc(docID, {style});
|
||||||
displayDialogStub.resetHistory();
|
displayDialogStub.resetHistory();
|
||||||
displayAlertStub.reset();
|
displayAlertStub.resetHistory();
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function* () {
|
after(function* () {
|
||||||
|
@ -559,7 +559,7 @@ describe("Zotero.Integration", function () {
|
||||||
assert.isTrue(getCiteprocBibliographySpy.calledOnce);
|
assert.isTrue(getCiteprocBibliographySpy.calledOnce);
|
||||||
|
|
||||||
assert.equal(getCiteprocBibliographySpy.lastCall.returnValue[0].entry_ids.length, 3);
|
assert.equal(getCiteprocBibliographySpy.lastCall.returnValue[0].entry_ids.length, 3);
|
||||||
getCiteprocBibliographySpy.reset();
|
getCiteprocBibliographySpy.resetHistory();
|
||||||
|
|
||||||
setAddEditItems(testItems[3]);
|
setAddEditItems(testItems[3]);
|
||||||
yield execCommand('addEditCitation', docID);
|
yield execCommand('addEditCitation', docID);
|
||||||
|
@ -580,7 +580,7 @@ describe("Zotero.Integration", function () {
|
||||||
assert.isTrue(getCiteprocBibliographySpy.calledOnce);
|
assert.isTrue(getCiteprocBibliographySpy.calledOnce);
|
||||||
|
|
||||||
assert.equal(getCiteprocBibliographySpy.lastCall.returnValue[0].entry_ids.length, 3);
|
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, 'cursorInField').resolves(doc.fields[1]);
|
||||||
sinon.stub(doc, 'canInsertField').resolves(false);
|
sinon.stub(doc, 'canInsertField').resolves(false);
|
||||||
|
@ -603,7 +603,7 @@ describe("Zotero.Integration", function () {
|
||||||
displayAlertStub = sinon.stub(DocumentPluginDummy.Document.prototype, 'displayAlert').resolves(0);
|
displayAlertStub = sinon.stub(DocumentPluginDummy.Document.prototype, 'displayAlert').resolves(0);
|
||||||
});
|
});
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
displayAlertStub.reset();
|
displayAlertStub.resetHistory();
|
||||||
});
|
});
|
||||||
after(function() {
|
after(function() {
|
||||||
displayAlertStub.restore();
|
displayAlertStub.restore();
|
||||||
|
|
|
@ -147,7 +147,7 @@ describe("Zotero.ItemTreeView", function() {
|
||||||
assert.equal(selected[0], existingItemID);
|
assert.equal(selected[0], existingItemID);
|
||||||
|
|
||||||
// Reset call count on spy
|
// Reset call count on spy
|
||||||
win.ZoteroPane.itemSelected.reset();
|
win.ZoteroPane.itemSelected.resetHistory();
|
||||||
|
|
||||||
// Create item with skipNotifier flag
|
// Create item with skipNotifier flag
|
||||||
var item = new Zotero.Item('book');
|
var item = new Zotero.Item('book');
|
||||||
|
@ -172,7 +172,7 @@ describe("Zotero.ItemTreeView", function() {
|
||||||
assert.equal(selected[0], existingItemID);
|
assert.equal(selected[0], existingItemID);
|
||||||
|
|
||||||
// Reset call count on spy
|
// Reset call count on spy
|
||||||
win.ZoteroPane.itemSelected.reset();
|
win.ZoteroPane.itemSelected.resetHistory();
|
||||||
|
|
||||||
// Create item with skipSelect flag
|
// Create item with skipSelect flag
|
||||||
var item = new Zotero.Item('book');
|
var item = new Zotero.Item('book');
|
||||||
|
@ -267,7 +267,7 @@ describe("Zotero.ItemTreeView", function() {
|
||||||
itemsView.selection.clearSelection();
|
itemsView.selection.clearSelection();
|
||||||
assert.lengthOf(itemsView.getSelectedItems(), 0);
|
assert.lengthOf(itemsView.getSelectedItems(), 0);
|
||||||
// Reset call count on spy
|
// Reset call count on spy
|
||||||
win.ZoteroPane.itemSelected.reset();
|
win.ZoteroPane.itemSelected.resetHistory();
|
||||||
|
|
||||||
// Modify item
|
// Modify item
|
||||||
item.setField('title', 'no select on modify');
|
item.setField('title', 'no select on modify');
|
||||||
|
@ -293,7 +293,7 @@ describe("Zotero.ItemTreeView", function() {
|
||||||
assert.equal(selected[0], id);
|
assert.equal(selected[0], id);
|
||||||
|
|
||||||
// Reset call count on spy
|
// Reset call count on spy
|
||||||
win.ZoteroPane.itemSelected.reset();
|
win.ZoteroPane.itemSelected.resetHistory();
|
||||||
|
|
||||||
// Modify item
|
// Modify item
|
||||||
item.setField('title', 'maintain selection on modify');
|
item.setField('title', 'maintain selection on modify');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue