mercredi 25 février 2015

Give Chai/Mocha a partial list of keys that should be included

It seems that if I do



describe( 'Add Youtube', function () {

it( 'should return the video data, including user, title and content fields', function ( done ) {

this.timeout( 5000 )

request({
method: 'POST',
url: 'https://localhost:8443/api/add',
json: true,
strictSSL: false,
body: {
"type": "youtube",
"url": "http://ift.tt/1LCl5pi"
},
headers: {
"Authorization": "Bearer " + newTestUser.token
} }, function ( err, response, body ) {

body.should.include.keys( [ "user", "title", "content" ] )

done()
})
})
})


That this will return an error since the object coming back also has the key message. How can I have this come back as passed as long as the 3 keys in the array are present, despite any more being there. I can't always predict what's going to be there in each case.


Aucun commentaire:

Enregistrer un commentaire