I'm using a promise to wait on a Facebook Graph response in the middle of a Mocha test. I'm wondering why the expect
function is not actually checking that the data is include
d in the response.
I see resolve
in the console, suggesting the graph call worked and the promise resolved, but the test passes, even though the event does not include the random data in the expect(data).to.include
statement. How can I get test the response when the promise resolves?
var promise = new Promise(function(resolve, reject) {
var eventFB1 = graph.get('132166232459578/posts',
{limit: 1,
access_token: 't0k3n'
});
if (typeof eventFB1 !== 'undefined') {
resolve(eventFB1);
console.log('resolve');
}
else {
reject(Error("It broke"));
console.log('reject');
}
});
return promise.then(function(data) {
expect(data).to.include( 'Event name: Testing London eveng 23498723rstni' );
console.log(data);
});