From 5a5a8a93f9b2fb8960b4231934fbd5694b6f761a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 1 Jun 2015 19:58:54 -0400 Subject: [PATCH] Zotero.Item::addTag() tests --- test/tests/itemTest.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js index a2af31274..e769c08f1 100644 --- a/test/tests/itemTest.js +++ b/test/tests/itemTest.js @@ -543,6 +543,51 @@ describe("Zotero.Item", function () { }) }) + describe("#addTag", function () { + it("should add a tag", function* () { + var item = createUnsavedDataObject('item'); + item.addTag('a'); + yield item.saveTx(); + var tags = item.getTags(); + assert.deepEqual(tags, [{ tag: 'a' }]); + }) + + it("should add two tags", function* () { + var item = createUnsavedDataObject('item'); + item.addTag('a'); + item.addTag('b'); + yield item.saveTx(); + var tags = item.getTags(); + assert.sameDeepMembers(tags, [{ tag: 'a' }, { tag: 'b' }]); + }) + + it("should add two tags of different types", function* () { + var item = createUnsavedDataObject('item'); + item.addTag('a'); + item.addTag('b', 1); + yield item.saveTx(); + var tags = item.getTags(); + assert.sameDeepMembers(tags, [{ tag: 'a' }, { tag: 'b', type: 1 }]); + }) + + it("should add a tag to an existing item", function* () { + var item = yield createDataObject('item'); + item.addTag('a'); + yield item.saveTx(); + var tags = item.getTags(); + assert.deepEqual(tags, [{ tag: 'a' }]); + }) + + it("should add two tags to an existing item", function* () { + var item = yield createDataObject('item'); + item.addTag('a'); + item.addTag('b'); + yield item.saveTx(); + var tags = item.getTags(); + assert.sameDeepMembers(tags, [{ tag: 'a' }, { tag: 'b' }]); + }) + }) + describe("#clone()", function () { // TODO: Expand to other data it("should copy creators", function* () {