cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesj...@apache.org
Subject spec commit: [CB-3942] add Contacts autotests cleanup
Date Fri, 21 Jun 2013 18:06:21 GMT
Updated Branches:
  refs/heads/2.9.x b6a73892a -> 9cb5d68d8


[CB-3942] add Contacts autotests cleanup

-cleanup contacts so future test runs on same device start clean
(cherry picked from commit 0cedea96df3ee5a94b702d2525720623e343d153)


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/9cb5d68d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/9cb5d68d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/9cb5d68d

Branch: refs/heads/2.9.x
Commit: 9cb5d68d8db6f0e132112e9cd63f799c17a0bb7f
Parents: b6a7389
Author: James Jong <wjamesjong@gmail.com>
Authored: Fri Jun 21 13:44:20 2013 -0400
Committer: James Jong <wjamesjong@gmail.com>
Committed: Fri Jun 21 14:04:32 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/9cb5d68d/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);
+        });
+    });
+
 });


Mime
View raw message