Github user daserge commented on a diff in the pull request:

    
https://github.com/apache/cordova-plugin-contacts/pull/87#discussion_r45990446
  
    --- Diff: tests/tests.js ---
    @@ -358,44 +380,68 @@ exports.defineAutoTests = function() {
                         pending();
                     }
     
    -                expect(gContactObj).toBeDefined();
    -
    -                var bDay = new Date(1975, 5, 4);
    +                var aDay = new Date(1976, 6, 4);
    +                var bDay;
                     var noteText = "an UPDATED note";
     
    -                var win = function(obj) {
    -                        expect(obj).toBeDefined();
    -                        expect(obj.id).toBe(gContactObj.id);
    -                        expect(obj.note).toBe(noteText);
    -                        
expect(obj.birthday.toDateString()).toBe(bDay.toDateString());
    -                        expect(obj.emails.length).toBe(1);
    -                        expect(obj.emails[0].value).toBe('[email protected]');
    -                        removeContact(); // Clean up contact object
    -                        done();
    +                var obj = {
    +                    "gender": "male",
    +                    "note": "my note",
    +                    "name": {
    +                        "familyName": "Delete",
    +                        "givenName": "Test"
                         },
    -                    fail = function() {
    -                        removeContact();
    -                        fail(done);
    -                    };
    +                    "emails": [{
    +                        "value": "[email protected]"
    +                    }, {
    +                        "value": "[email protected]"
    +                    }],
    +                    "birthday": aDay
    +                };
    +
    +                var saveFail = fail.bind(null, done);
    +
    +                var saveSuccess = function(obj) {
    +                    // must store returned object in order to have id for 
update test below
    +                    gContactObj = obj;
    +                    gContactObj.emails[1].value = "";
    +                    bDay = new Date(1975, 5, 4);
    +                    gContactObj.birthday = bDay;
    +                    gContactObj.note = noteText;
    +                    gContactObj.save(updateSuccess, saveFail);
    +                };
    +
    +                var updateSuccess = function(obj) {
    +                    expect(obj).toBeDefined();
    +                    expect(obj.id).toBe(gContactObj.id);
    +                    expect(obj.note).toBe(noteText);
    +                    
expect(obj.birthday.toDateString()).toBe(bDay.toDateString());
    +                    expect(obj.emails.length).toBe(1);
    +                    expect(obj.emails[0].value).toBe('[email protected]');
    +                    done();
    +                };
    +
    +                navigator.contacts
    +                    .create(obj)
    +                    .save(saveSuccess, saveFail);
     
    -                // remove an email
    -                gContactObj.emails[1].value = "";
    -                // change birthday
    -                gContactObj.birthday = bDay;
    -                // update note
    -                gContactObj.note = noteText;
    -                gContactObj.save(win, fail);
                 }, MEDIUM_TIMEOUT);
             });
    +
             describe('Contact.remove method', function(done) {
    -            afterEach(removeContact);
    +            afterEach(function (done) {
    +                removeContact(done);
    +            });
     
                 it("contacts.spec.22 calling remove on a contact has an id of 
null should return ContactError.UNKNOWN_ERROR", function(done) {
    -                var win = function() {};
    +                var win = function() {
    +                    expect(false).toBe(true);
    --- End diff --
    
    IMO this might be rewritten to use the global `fail` function as in spec.23 
and others, i.e. use `fail.bind` as it does the same thing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to