Test spies and stubs with Sinon.JS
We have been working on the MathDemo
class. We have implemented and tested its features using unit tests and assertions. Now we are going to create a little web widget that will internally use the MathDemo
class to perform a mathematical operation. We can think of this new class as a graphical user interface for the MathDemo
class. We need the following HTML:
<div id="widget"> <input type="text" id="base" /> <input type="text" id="exponent" /> <input type="text" id="result" /> <button id="submit" type="submit">Submit</button> </div>
Note
In the companion code, the HTML code contains more attributes, such as CSS classes; but they been have removed here for clarity.
Let's create a file named calculator_widget.ts
under ...
Get TypeScript: Modern JavaScript Development 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.