hello I have a method which returns me data along with URL , so return object has url and body as two properties.
return new Promise(function(resolve,reject)
{
request(url, function (error, response, body) {
if(error)
reject(error);
else
{
if(response.statusCode ==200)
resolve( { "url" :url , "body" : body});
else
reject("error while getting response from " + url);
}
});
});
How should I test this in Chai- as promised
it works for 1 property.
it("get data from correct url", function(){
return expect (httphelper.getWebPageContent(config.WebUrl))
.to.eventually.have.property('url')
});
if I include other property it searches inside previous property.
it("get data from correct url", function(){
return expect (httphelper.getWebPageContent(config.WebUrl))
.to.eventually.have.property('url')
.and.to.have.property('body')
});
AssertionError: expected 'http://www.jsondiff.com/' to have property 'body'
where I'm going wrong?
Create an object with the expected properties :
Then ensure the result include this properties with :