I am testing an api which already has a callback inside a callback at the end of the function. I want to wrap this in a test to verify the object is correct but this doesn't seem to be working. callbackEnd() gets called but that's it.
In the library on a script load success:
function callback() {
// populate gpt object
if(typeof callbackEnd === 'function') {
callbackEnd();
}
}
Mocha.js test:
"use strict";
(function() {
describe("Callback Success", function() {
function callbackEnd() {
console.log('callbackEnd() called');
it('GPT returned advars', function() {
expect(Object.keys(someobj).length).to.beGreaterThan(0);
console.log('GPT loaded successfully, ' + Object.keys(someobj).length);
});
}
});
})();
There it goes, describe -> it -> custom callback function -> done();