Integrate and Run
We need one final function that integrates all the functions together and for that, we need a few integration tests. Letâs start with the integration tests; you can also key these into the stockfetch-test.js file:
â | it(â'getPriceForTickers should report error for invalid file'â, |
â | âfunctionâ(done) { |
â | âvarâ onError = âfunctionâ(error) { |
â | expect(error).to.be.eql(â'Error reading file: InvalidFile'â); |
â | done(); |
â | }; |
â | âvarâ display = âfunctionâ() {}; |
â | |
â | stockfetch.getPriceForTickers(â'InvalidFile'â, display, onError); |
â | }); |
â | |
â | it(â'getPriceForTickers should respond well for a valid file'â, |
â | âfunctionâ(done) { |
â | âvarâ onError = sandbox.mock().never(); ... |
Get Test-Driving JavaScript Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.