Asynchronous code testing of React-app

promise.js
promise.spec.js
expected output
api.js
api.spec.js
expected outcome
function callbackBasedFunc(number, cb) {
cb(number * 2);
}
describe("Async Code Test cases::", () => {
test(“to check multiplication once callback finish:”, (done) => {
function callback(data) {
expect(data).toEqual(4);
done();
}
callbackBasedFunc(2, callback);
});
});

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store