11
22describe ( "calculator" , function ( ) {
3- let calculator ;
4- before ( function ( ) {
5- sinon . stub ( window , "prompt" )
6-
7- prompt . onCall ( 0 ) . returns ( "2" ) ;
8- prompt . onCall ( 1 ) . returns ( "3" ) ;
9-
10- calculator = new Calculator ( ) ;
11- calculator . read ( ) ;
12- } ) ;
13-
14- it ( "the read method asks for two values using prompt and remembers them in object properties" , function ( ) {
15- assert . equal ( calculator . a , 2 ) ;
16- assert . equal ( calculator . b , 3 ) ;
17- } ) ;
18-
19- it ( "when 2 and 3 are entered, the sum is 5" , function ( ) {
20- assert . equal ( calculator . sum ( ) , 5 ) ;
21- } ) ;
22-
23- it ( "when 2 and 3 are entered, the product is 6" , function ( ) {
24- assert . equal ( calculator . mul ( ) , 6 ) ;
25- } ) ;
3+ let calculator ;
4+ before ( function ( ) {
5+ sinon . stub ( window , "prompt" )
6+
7+ prompt . onCall ( 0 ) . returns ( "2" ) ;
8+ prompt . onCall ( 1 ) . returns ( "3" ) ;
9+
10+ calculator = new Calculator ( ) ;
11+ calculator . read ( ) ;
12+ } ) ;
2613
27- after ( function ( ) {
28- prompt . restore ( ) ;
29- } ) ;
14+ it ( "the read method asks for two values using prompt and remembers them in object properties" , function ( ) {
15+ assert . equal ( calculator . a , 2 ) ;
16+ assert . equal ( calculator . b , 3 ) ;
17+ } ) ;
18+
19+ it ( "when 2 and 3 are entered, the sum is 5" , function ( ) {
20+ assert . equal ( calculator . sum ( ) , 5 ) ;
21+ } ) ;
22+
23+ it ( "when 2 and 3 are entered, the product is 6" , function ( ) {
24+ assert . equal ( calculator . mul ( ) , 6 ) ;
25+ } ) ;
26+
27+ after ( function ( ) {
28+ prompt . restore ( ) ;
3029 } ) ;
31-
30+ } ) ;
0 commit comments