cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omef...@apache.org
Subject cordova-plugin-contacts git commit: Revert "CB-10881 Add extra logging to gather more information about tests behavior"
Date Wed, 06 Apr 2016 18:50:22 GMT
Repository: cordova-plugin-contacts
Updated Branches:
  refs/heads/master 7bec3a5e9 -> c184b4e48


Revert "CB-10881 Add extra logging to gather more information about tests behavior"

This reverts commit 8a08f75cad9e6b127884e9e5e2fae3e44225c702.

 Conflicts:
	tests/tests.js. This closes #117


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/c184b4e4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/c184b4e4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/c184b4e4

Branch: refs/heads/master
Commit: c184b4e48ba3983ee4a2681cdf5fee471f076fa1
Parents: 7bec3a5
Author: Omar Mefire <omefire@gmail.com>
Authored: Tue Apr 5 15:17:54 2016 -0700
Committer: Omar Mefire <omefire@gmail.com>
Committed: Wed Apr 6 11:50:05 2016 -0700

----------------------------------------------------------------------
 tests/tests.js | 102 +++++-----------------------------------------------
 1 file changed, 9 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/c184b4e4/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 1155a77..0ce5f6e 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -114,24 +114,6 @@ exports.defineAutoTests = function() {
         }, done, obj);
     }
 
-    // Convert seconds to HH:MM:SS format: http://stackoverflow.com/a/6313008/91607
-    function toHHMMSS(secs) {
-        var sec_num = parseInt(secs, 10); // don't forget the second param
-        var hours   = Math.floor(sec_num / 3600);
-        var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
-        var seconds = sec_num - (hours * 3600) - (minutes * 60);
-
-        if (hours   < 10) {hours   = "0" + hours;}
-        if (minutes < 10) {minutes = "0" + minutes;}
-        if (seconds < 10) {seconds = "0" + seconds;}
-        var time = hours + ':' + minutes  + ':' + seconds;
-        return time;
-    }
-
-    function getTimeInHHMMSS(date) {
-        return date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
-    }
-
     describe("Contacts (navigator.contacts)", function() {
         this.contactObj = null;
 
@@ -473,10 +455,6 @@ exports.defineAutoTests = function() {
             });
 
             it("contacts.spec.22 update a contact", function(done) {
-
-                var startTime = new Date();
-                console.log("Spec22 - Start Time: " + getTimeInHHMMSS(startTime));
-
                 // Save method is not supported on Windows platform
                 if (isWindows || isWindowsPhone8 || isIOSPermissionBlocked) {
                     pending();
@@ -503,12 +481,7 @@ exports.defineAutoTests = function() {
                     "birthday": aDay
                 };
 
-                var saveFail = function() {
-                    var endTime = new Date();
-                    console.log("Spec22 - EndTime: " + getTimeInHHMMSS(endTime));
-                    console.log("Time Elapsed: " + toHHMMSS( (startTime.getTime() / 1000)
- (endTime.getTime() / 1000) ));
-                    fail.bind(null, done);
-                };
+                var saveFail = fail.bind(null, done);
 
                 function updateSuccess(obj) {
                     specContext.contactObj = obj;
@@ -518,11 +491,6 @@ exports.defineAutoTests = function() {
                     expect(obj.birthday.toDateString()).toBe(bDay.toDateString());
                     expect(obj.emails.length).toBe(1);
                     expect(obj.emails[0].value).toBe('here@there.com');
-
-                    var endTime = new Date();
-                    console.log("Spec22 - EndTime: " + getTimeInHHMMSS(endTime));
-                    console.log("Time Elapsed: " + toHHMMSS( (startTime.getTime() / 1000)
- (endTime.getTime() / 1000) ));
-
                     done();
                 }
 
@@ -549,28 +517,13 @@ exports.defineAutoTests = function() {
             });
 
             it("contacts.spec.23 calling remove on a contact that has an id of null should
return ContactError.UNKNOWN_ERROR", function(done) {
-                var startTime = new Date();
-                console.log("Spec23 - Start Time: " + getTimeInHHMMSS(startTime));
-
-                var unexpectedSuccess = function() {
-                    var endTime = new Date();
-                    console.log("Spec23 - EndTime: " + getTimeInHHMMSS(endTime));
-                    console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime
/ 1000) ));
-
-                    fail.bind(null, done);
-                };
                 var expectedFail = function(result) {
                     expect(result.code).toBe(ContactError.UNKNOWN_ERROR);
-
-                    var endTime = new Date();
-                    console.log("Spec23 - EndTime: " + getTimeInHHMMSS(endTime));
-                    console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime
/ 1000) ));
-
                     done();
                 };
 
                 var rmContact = new Contact();
-                rmContact.remove(unexpectedSuccess, expectedFail);
+                rmContact.remove(fail.bind(null, done), expectedFail);
             });
 
             it("contacts.spec.24 calling remove on a contact that does not exist should return
ContactError.UNKNOWN_ERROR", function(done) {
@@ -627,12 +580,8 @@ exports.defineAutoTests = function() {
             }, MEDIUM_TIMEOUT);
 
             it("contacts.spec.26 Creating, saving, finding a contact should work, removing
it should work", function(done) {
-
-                var specContext = this;
-                var startTime = new Date();
-                console.log("Spec26 - Start Time: " + getTimeInHHMMSS(startTime));
-
                 // Save method is not supported on Windows platform
+                var specContext = this;
                 if (isWindows || isWindowsPhone8 || isIOSPermissionBlocked) {
                     pending();
                 }
@@ -643,65 +592,32 @@ exports.defineAutoTests = function() {
                 contact.note = "DeleteMe";
                 saveAndFindBy(contact, ["displayName", "name"], contactName, function(savedContact)
{
                     savedContact.remove(function() {
-                        var endTime = new Date();
                         specContext.contactObj = null;
-                        console.log("Spec26 - EndTime: " + getTimeInHHMMSS(endTime));
-                        console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime
/ 1000) ));
-
                         done();
                     }, function(e) {
-
-                        var endTime = new Date();
-                        console.log("Spec26 - EndTime: " + getTimeInHHMMSS(endTime));
-                        console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime
/ 1000) ));
-
                         throw ("Newly created contact's remove function invoked error callback.
Test failed: " + JSON.stringify(e));
                     });
                 }, this);
             }, MEDIUM_TIMEOUT);
 
             it("contacts.spec.27 Should not be able to delete the same contact twice", function(done)
{
-
-                var startTime = new Date();
-                console.log("Spec27 - Start Time: " + getTimeInHHMMSS(startTime));
-
                 // Save method is not supported on Windows platform
                 if (isWindows || isWindowsPhone8 || isIOSPermissionBlocked) {
                     pending();
                 }
-                var specContext = this;
                 var contactName = "DeleteMe2";
                 var contact = new Contact();
                 contact.name = new ContactName();
                 contact.name.familyName = contactName;
                 contact.note = "DeleteMe2";
-
-                var failureHandler = function() {
-                    console.log("Inside failureHandler");
-                    var endTime = new Date();
-                    console.log("Spec27 - EndTime: " + endTime);
-                    console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime
/ 1000) ));
-                };
-
-                saveAndFindBy(contact, ["displayName", "name"], contactName, function(savedContact)
{
-                    savedContact.remove(function() {
-                        specContext.contactObj = null;
+                saveAndFindBy(contact, ["displayName", "name"], contactName, function() {
+                    contact.remove(function() {
                         var findWin = function(seas) {
                             expect(seas.length).toBe(0);
-                            savedContact.remove(function(e) {
-
-                                var endTime = new Date();
-                                console.log("Spec27 - EndTime: " + getTimeInHHMMSS(endTime));
-                                console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000)
- (endTime / 1000) ));
-
-                                throw ("Success callback called after non-existent Contact
object called remove(). Test failed: " + JSON.stringify(e));
+                            contact.remove(function() {
+                                throw ("Success callback called after non-existent Contact
object called remove(). Test failed.");
                             }, function(e) {
-
-                                console.log("Inside contact.remove() failure callback");
-                                var endTime = new Date();
-                                console.log("Spec27 - EndTime: " + getTimeInHHMMSS(endTime));
-                                console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000)
- (endTime / 1000) ));
-
+                                contact = null;
                                 expect(e.code).toBe(ContactError.UNKNOWN_ERROR);
                                 done();
                             });
@@ -710,7 +626,7 @@ exports.defineAutoTests = function() {
                         obj.filter = contactName;
                         obj.multiple = true;
                         navigator.contacts.find(["displayName", "name", "phoneNumbers", "emails"],
findWin, fail, obj);
-                    }, failureHandler);
+                    }, fail);
                 }, this);
             }, MEDIUM_TIMEOUT);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message