You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ja...@apache.org on 2013/06/21 19:48:31 UTC

spec commit: [CB-3942] add Contacts autotests cleanup

Updated Branches:
  refs/heads/master d5eb15a44 -> 0cedea96d


[CB-3942] add Contacts autotests cleanup

-cleanup contacts so future test runs on same device start clean


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/0cedea96
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/0cedea96
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/0cedea96

Branch: refs/heads/master
Commit: 0cedea96df3ee5a94b702d2525720623e343d153
Parents: d5eb15a
Author: James Jong <wj...@gmail.com>
Authored: Fri Jun 21 13:44:20 2013 -0400
Committer: James Jong <wj...@gmail.com>
Committed: Fri Jun 21 13:44:20 2013 -0400

----------------------------------------------------------------------
 autotest/tests/contacts.tests.js | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0cedea96/autotest/tests/contacts.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/contacts.tests.js b/autotest/tests/contacts.tests.js
index 6d03e45..de890f8 100644
--- a/autotest/tests/contacts.tests.js
+++ b/autotest/tests/contacts.tests.js
@@ -64,7 +64,7 @@ describe("Contacts (navigator.contacts)", function () {
                 expect(fail).not.toHaveBeenCalled();
             });
         });
-        
+
         it("success callback should be called with an array, even if partial ContactFindOptions specified", function () {
             var win = jasmine.createSpy().andCallFake(function (result) {
                 expect(result).toBeDefined();
@@ -428,8 +428,6 @@ describe("Contacts (navigator.contacts)", function () {
     });
 
     describe("Round trip Contact tests (creating + save + delete + find).", function () {
-        afterEach(removeContact);
-
         it("contacts.spec.24 Creating, saving, finding a contact should work, removing it should work, after which we should not be able to find it, and we should not be able to delete it again.", function() {
             var done = false;
             runs(function () {
@@ -489,4 +487,35 @@ describe("Contacts (navigator.contacts)", function () {
             expect(ContactError.PERMISSION_DENIED_ERROR).toBe(20);
         });
     });
+
+    describe("Contacts autotests cleanup", function () {
+        it("contacts.spec.26 Cleanup any DeleteMe contacts from Contacts tests.", function() {
+            var done = false;
+            var obj = new ContactFindOptions();
+            obj.filter="DeleteMe";
+            obj.multiple=true;
+            runs(function () {
+                var findSuccess = function (cs) {
+                    var contactObj = new Contact();
+                    if (cs.length>0){
+                        contactObj = cs[0];
+                        contactObj.remove(function(){
+                            console.log("[CONTACTS CLEANUP] DeleteMe contact successfully removed");
+                            navigator.contacts.find(["displayName", "name", "phoneNumbers", "emails"], findSuccess, findFail, obj);
+                        },function(){
+                            console.log("[CONTACTS CLEANUP ERROR]: failed to remove DeleteMe contact");
+                        });
+                    } else {
+                        done = true;
+                    };
+                };
+                var findFail = function(e) {
+                    throw("Failure callback invoked in navigator.contacts.find call, test failed.");
+                };
+                navigator.contacts.find(["displayName", "name", "phoneNumbers", "emails"], findSuccess, findFail, obj);
+            });
+            waitsFor(function () { return done; }, Tests.TEST_TIMEOUT);
+        });
+    });
+
 });