From 2c136ffbb09c78d8f41481f893c89e10a80b41a5 Mon Sep 17 00:00:00 2001 From: Frank Bennett Date: Wed, 13 Feb 2019 00:09:35 +0900 Subject: [PATCH] Add test of multiple new insertions with implicit update on the first --- test/tests/integrationTest.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/test/tests/integrationTest.js b/test/tests/integrationTest.js index b5711da826..a537425a72 100644 --- a/test/tests/integrationTest.js +++ b/test/tests/integrationTest.js @@ -486,8 +486,34 @@ describe("Zotero.Integration", function () { setAddEditItems(testItems[4]); yield execCommand('addEditCitation', docID); assert.equal(doc.fields.length, 3); - assert.equal(Zotero.Integration.currentSession.style.registry.registry[testItems[4].id].disambig.year_suffix, '0'); - assert.equal(Zotero.Integration.currentSession.style.registry.registry[testItems[3].id].disambig.year_suffix, '1'); + assert.equal(doc.fields[0].text, "(Smith, 2019a)"); + assert.equal(doc.fields[2].text, "(Smith, 2019b)"); + }); + + it('should place an implicitly updated citation correctly after multiple new insertions', function* () { + yield insertMultipleCitations.call(this); + var docID = this.test.fullTitle(); + var doc = applications[docID].doc; + + testItems[3].setCreator(0, {creatorType: 'author', lastName: 'Smith', firstName: 'Robert'}); + testItems[3].setField('date', '2019-01-01'); + + setAddEditItems(testItems[3]); + yield execCommand('addEditCitation', docID); + assert.equal(doc.fields[2].text, "(Smith, 2019)"); + + sinon.stub(doc, 'cursorInField').resolves(doc.fields[0]); + sinon.stub(doc, 'canInsertField').resolves(false); + + doc.fields[1].code = doc.fields[0].code; + doc.fields[1].text = doc.fields[0].text; + + testItems[4].setCreator(0, {creatorType: 'author', lastName: 'Smith', firstName: 'Robert'}); + testItems[4].setField('date', '2019-01-01'); + + setAddEditItems(testItems[4]); + yield execCommand('addEditCitation', docID); + assert.equal(doc.fields.length, 3); assert.equal(doc.fields[0].text, "(Smith, 2019a)"); assert.equal(doc.fields[2].text, "(Smith, 2019b)"); });