O'Reilly logo

TypeScript: Modern JavaScript Development by Ivo Gabe de Wolff, Vilic Vane, Remo H. Jansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required