Merge pull request #1639 from Juris-M/zmaster-test-bib-update

Test for bibliography sort update on change to item
This commit is contained in:
Adomas Ven 2019-02-12 10:32:04 +02:00 committed by GitHub
commit 9ddd4dda3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;