Frage

I'm trying to run the following tests:

describe('set()', function () {
    var returnedUser = session.set(user);

    it('should return a User object', function () {
        //this works fine
        return returnedUser.should.eventually.equal(user);
    });

    it('returned User object should have sessionId appended', function() {
        //DOES NOT WORK; always passes
        return returnedUser.should.eventually.hasOwnProperty('thisdoesnotexist');
    });
});

I'm trying to figure out the right syntax to test whether the returned User object contains a 'sessionId' property. Does anybody know how to do it?

War es hilfreich?

Lösung

Figured this out by looking a little more closely at the chaijs docs.

it('returned User object should have sessionId appended', function() {
    return returnedUser.should.eventually.include.keys('sessionId');
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top