From 0e18c5f1dee8085b5c827419e7a1dd4a4f20acee Mon Sep 17 00:00:00 2001 From: Frank Bennett Date: Sun, 10 Feb 2019 11:07:10 +0900 Subject: [PATCH] Test for bibliography sort update on change to item --- test/tests/integrationTest.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/tests/integrationTest.js b/test/tests/integrationTest.js index 1599c81b90..a2f452feb0 100644 --- a/test/tests/integrationTest.js +++ b/test/tests/integrationTest.js @@ -485,6 +485,35 @@ describe("Zotero.Integration", function () { getCiteprocBibliographySpy.restore(); }); + + it('should update bibliography sort order on change to item', function* () { + yield insertMultipleCitations.call(this); + var docID = this.test.fullTitle(); + var doc = applications[docID].doc; + + let getCiteprocBibliographySpy = + sinon.spy(Zotero.Integration.Bibliography.prototype, 'getCiteprocBibliography'); + + yield execCommand('addEditBibliography', docID); + assert.isTrue(getCiteprocBibliographySpy.calledOnce); + + assert.equal(getCiteprocBibliographySpy.lastCall.returnValue[0].entry_ids.length, 3); + getCiteprocBibliographySpy.reset(); + + sinon.stub(doc, 'cursorInField').resolves(doc.fields[1]); + sinon.stub(doc, 'canInsertField').resolves(false); + + testItems[1].setCreator(0, {creatorType: 'author', name: 'Aaaaa'}); + testItems[1].setField('title', 'Bbbbb'); + + setAddEditItems(testItems.slice(1, 3)); + yield execCommand('addEditCitation', docID); + + assert.equal(getCiteprocBibliographySpy.lastCall.returnValue[0].entry_ids.length, 3); + assert.equal(getCiteprocBibliographySpy.lastCall.returnValue[1][0], "Aaaaa Bbbbb."); + + getCiteprocBibliographySpy.restore(); + }); describe('when original citation text has been modified', function() { var displayAlertStub;