I've got an object like this:
var obj = {
"uuid": "60afc3fa-920d-11e5-bd17-b9db323e7d51",
"type": "candy"
}
I want to write a test that checks first that the object has the property 'uuid' in the first place, and then that 'uuid' is a specific length (36 chars).
Trying this doesn't work
obj.should.have.property('uuid').which.should.have.length(36)
It fails with:
Uncaught AssertionError: expected Assertion {
obj: '60afc3fa-920d-11e5-bd17-b9db323e7d51',
params: { operator: 'to have property \'uuid\'' },
negate: false } to have property 'length' of 36 (got [Function])
And this (which actually doesn't make syntactic sense anyway - since it would apply to the parent object not the value)
obj.should.have.property('uuid').and.be.length(36)
Which fails with:
Uncaught TypeError: usergridResponse.entity.should.have.property(...).which.should.be.equal.to is not a function
Even this doesn't work:
obj.should.have.property('uuid').which.equals('60afc3fa-920d-11e5-bd17-b9db323e7d51')
So what's the correct way to chain assertions on the property of an object?