commit 5a5a8a93f9b2fb8960b4231934fbd5694b6f761a
parent b59fa1eed9e4403c9d92d5aef0c1887bded8aea5
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 1 Jun 2015 19:58:54 -0400
Zotero.Item::addTag() tests
Diffstat:
1 file changed, 45 insertions(+), 0 deletions(-)
diff --git 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* () {