Tests for data layer and item fixes/changes
This commit is contained in:
parent
8ff258fe03
commit
db2348f100
2 changed files with 80 additions and 0 deletions
44
test/tests/itemTest.js
Normal file
44
test/tests/itemTest.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
describe("Zotero.Item", function() {
|
||||
describe("#getField()", function () {
|
||||
it("should return false for valid unset fields on unsaved items", function* () {
|
||||
var item = new Zotero.Item('book');
|
||||
item.libraryID = Zotero.Libraries.userLibraryID;
|
||||
assert.equal(item.getField('rights'), false);
|
||||
});
|
||||
|
||||
it("should return false for valid unset fields on unsaved items after setting on another field", function* () {
|
||||
var item = new Zotero.Item('book');
|
||||
item.libraryID = Zotero.Libraries.userLibraryID;
|
||||
item.setField('title', 'foo');
|
||||
assert.equal(item.getField('rights'), false);
|
||||
});
|
||||
|
||||
it("should return false for invalid unset fields on unsaved items after setting on another field", function* () {
|
||||
var item = new Zotero.Item('book');
|
||||
item.libraryID = Zotero.Libraries.userLibraryID;
|
||||
item.setField('title', 'foo');
|
||||
assert.equal(item.getField('invalid'), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#parentID", function () {
|
||||
it("should create a child note", function () {
|
||||
return Zotero.DB.executeTransaction(function* () {
|
||||
var item = new Zotero.Item('book');
|
||||
item.libraryID = Zotero.Libraries.userLibraryID;
|
||||
var parentItemID = yield item.save();
|
||||
|
||||
item = new Zotero.Item('note');
|
||||
item.libraryID = Zotero.Libraries.userLibraryID;
|
||||
item.parentID = parentItemID;
|
||||
var childItemID = yield item.save();
|
||||
|
||||
item = yield Zotero.Items.getAsync(childItemID);
|
||||
Zotero.debug('=-=-=');
|
||||
Zotero.debug(item.parentID);
|
||||
assert.ok(item.parentID);
|
||||
assert.equal(item.parentID, parentItemID);
|
||||
}.bind(this));
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue