unit testing - how to write a test for Javascript -
i attempting write test code having problems.
const attemptfinish = (taskid, then) => (disp) => { return api .finishtask(taskid) .then(then); }; export default attemptfinish;
the finishtask function so
finishtask(taskid) { return ajaclass .post(host + '/comptask/mark', { id: taskid }); }
i using sinon try , create response used results. has promise makes more complex
describe ("attemptfinish assess actions", () => { var participantid = 145; var prom = new promise((resolve, reject) => { resolve(); }); it("should return", () => { var astub = sinon.stub(api, "finishtask") astub.withargs(participantid, " "); var callback = sinon.spy(); attemptfinish(participantid, prom) astub.restore(); }); });
Comments
Post a Comment