You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/03/15 17:57:19 UTC
spec commit: Update contact tests to run properly
Updated Branches:
refs/heads/master e1c585073 -> 734cfa37c
Update contact tests to run properly
*Need to create ContactName object before assigning value
*After saving an object, update the gContactObj global with the returned contact in order to have proper id value.
*removed test for saved contact and origin contact to match. Id will be different after a save and
for iOS at least, some fields may have been modified. Example, iOS will always return ContactName.formatted if an entire ContactName field is requested.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/734cfa37
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/734cfa37
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/734cfa37
Branch: refs/heads/master
Commit: 734cfa37caf2b20a848aaa5d26cb38e2e541e25e
Parents: e1c5850
Author: Becky Gibson <be...@apache.org>
Authored: Thu Mar 15 09:34:03 2012 -0400
Committer: Becky Gibson <be...@apache.org>
Committed: Thu Mar 15 09:34:03 2012 -0400
----------------------------------------------------------------------
autotest/tests/contacts.tests.js | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/734cfa37/autotest/tests/contacts.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/contacts.tests.js b/autotest/tests/contacts.tests.js
index faf72db..bfba15c 100644
--- a/autotest/tests/contacts.tests.js
+++ b/autotest/tests/contacts.tests.js
@@ -77,10 +77,13 @@ Tests.prototype.ContactsTests = function() {
// Helper save/create invocations+asserts
// ----
gContactObj = new Contact();
+ gContactObj.name = new ContactName();
gContactObj.name.familyName = "Delete";
gContactObj.save(
- function() {
+ function(savedContact) {
ok(true, "Contact's save success callback needs to fire for this test to pass");
+ // update so contact will get removed
+ gContactObj = savedContact;
// ----
// Find asserts
// ---
@@ -269,10 +272,12 @@ Tests.prototype.ContactsTests = function() {
ok(obj.emails[1].value == 'there@here.com', "Contact.emails[2] should contain a value.");
ok(obj.birthday instanceof Date && obj.birthday.toDateString() == bDay.toDateString(), "Contact should be a date object equal to " + bDay.toDateString());
ok(obj.addresses == null, "Contact should return null for addresses.");
+ // must store returned object in order to have id for update test below
+ gContactObj = obj;
QUnit.start();
};
- testContact.save(saveSuccess, function(e) {
+ gContactObj.save(saveSuccess, function(e) {
ok(false, "save method error callback called, test failed.");
QUnit.start();
});
@@ -351,21 +356,24 @@ Tests.prototype.ContactsTests = function() {
teardown:removeContact
});
test("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() {
- expect(9);
+ expect(8);
QUnit.stop(7000);
gContactObj = new Contact();
+ gContactObj.name = new ContactName();
gContactObj.name.familyName = "DeleteMe";
gContactObj.save(function(c_obj) {
ok(true, "Contact creation + saving succeeded, proceeding with test.");
var findWin = function(cs) {
ok(true, "contacts.find success callback invoked, proceeding with test.");
- equal(cs.length, 1, "contacts.find success callback should return only 1 item (no on has a contact with 'DeleteMe') as a family name.");
- deepEqual(cs[0], gContactObj, "returned Contact object should equal the initially-created Contact object.");
+ equal(cs.length, 1, "contacts.find success callback should return only 1 item (no one has a contact with 'DeleteMe') as a family name.");
+ //deepEqual(cs[0], gContactObj, "returned Contact object should equal the initially-created Contact object.");
+ // update to have proper saved id
+ gContactObj = cs[0];
gContactObj.remove(function() {
ok(true, "Newly created contact's remove function success callback called, proceeding with test.");
var findWinAgain = function(seas) {
- ok(true, "Calling find after deleting contact should e a success, proceeding.");
+ ok(true, "Calling find after deleting contact should be a success, proceeding.");
equal(seas.length, 0, "find post-remove should return zero length array of results.");
gContactObj.remove(function() {
ok(false, "success callback called after non-existent Contact object called remove(). Test failed.");