Mendeley importer: Fix issue with empty tags (#3018)
Also adds a test for this particular case and for importing tags in general.
This commit is contained in:
parent
96022847d7
commit
a6042d3958
4 changed files with 83 additions and 3 deletions
|
@ -176,6 +176,11 @@ describe('Zotero_Import_Mendeley', function () {
|
|||
.filter(item => item.libraryID == Zotero.Libraries.userLibraryID && !item.deleted)
|
||||
.shift();
|
||||
|
||||
const withTags = (await Zotero.Relations
|
||||
.getByPredicateAndObject('item', 'mendeleyDB:documentUUID', '4308d8ec-e8ea-43fb-9d38-4e6628f7c10a'))
|
||||
.filter(item => item.libraryID == Zotero.Libraries.userLibraryID && !item.deleted)
|
||||
.shift();
|
||||
|
||||
|
||||
assert.equal(journal.getRelations()['mendeleyDB:remoteDocumentUUID'], '7fea3cb3-f97d-3f16-8fad-f59caaa71688');
|
||||
assert.equal(journal.getField('title'), 'Foo Bar');
|
||||
|
@ -197,6 +202,17 @@ describe('Zotero_Import_Mendeley', function () {
|
|||
assert.equal(journal.getField('DOI'), '10.1111');
|
||||
assert.sameMembers(journal.getField('extra').split('\n'), ['PMID: 11111111', 'arXiv: 1111.2222']);
|
||||
|
||||
// tags
|
||||
assert.equal(withTags.getTags().length, 4);
|
||||
assert.sameMembers(
|
||||
withTags.getTags().filter(t => t.type === 1).map(t => t.tag),
|
||||
['keyword1', 'keyword2']
|
||||
);
|
||||
assert.sameMembers(
|
||||
withTags.getTags().filter(t => !t.type).map(t => t.tag),
|
||||
['tag1', 'tag2']
|
||||
);
|
||||
|
||||
// attachment & annotations
|
||||
assert.lengthOf(withpdf.getAttachments(), 1);
|
||||
assert.equal(pdf.parentID, withpdf.id);
|
||||
|
@ -453,14 +469,14 @@ describe('Zotero_Import_Mendeley', function () {
|
|||
assert.lengthOf(noNewItemHere, 0);
|
||||
});
|
||||
|
||||
it("should handle empty creators", async () => {
|
||||
it("should handle empty creators and tags", async () => {
|
||||
setHTTPResponse(server, 'https://api.mendeley.com/', {
|
||||
method: 'GET',
|
||||
url: `documents?view=all&limit=500`,
|
||||
status: 200,
|
||||
headers: {},
|
||||
json: JSON.parse(
|
||||
await Zotero.File.getContentsFromURLAsync('resource://zotero-unit-tests/data/mendeleyMock/items-empty-creators.json')
|
||||
await Zotero.File.getContentsFromURLAsync('resource://zotero-unit-tests/data/mendeleyMock/items-bad-data.json')
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -486,6 +502,14 @@ describe('Zotero_Import_Mendeley', function () {
|
|||
|
||||
assert.equal(journalEmptyAuthors.getField('title'), 'This one has empty authors');
|
||||
assert.equal(journalEmptyAuthors.getCreators().length, 0);
|
||||
|
||||
const journalEmptyTags = (await Zotero.Relations
|
||||
.getByPredicateAndObject('item', 'mendeleyDB:documentUUID', 'c7ec2737-044a-493b-9d94-d7f67be68765'))
|
||||
.filter(item => item.libraryID == Zotero.Libraries.userLibraryID && !item.deleted)
|
||||
.shift();
|
||||
|
||||
assert.equal(journalEmptyTags.getField('title'), 'This one has empty tags and keywords');
|
||||
assert.equal(journalEmptyTags.getTags().length, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue