@@ -94,8 +94,58 @@ describe('Arithmetic', function () {
9494 } ) ;
9595
9696// TODO: Challenge #1
97-
98-
97+ // add tests for subtraction
98+ describe ( 'Subtraction' , function ( ) {
99+ it ( 'subtracts two positive integers' , function ( done ) {
100+ request . get ( '/arithmetic?operation=subtract&operand1=21&operand2=18' )
101+ . expect ( 200 )
102+ . end ( function ( err , res ) {
103+ expect ( res . body ) . to . eql ( { result : 3 } ) ;
104+ done ( ) ;
105+ } ) ;
106+ } ) ;
107+ it ( 'subtracts a positive integer from zero' , function ( done ) {
108+ request . get ( '/arithmetic?operation=subtract&operand1=0&operand2=21' )
109+ . expect ( 200 )
110+ . end ( function ( err , res ) {
111+ expect ( res . body ) . to . eql ( { result : - 21 } ) ;
112+ done ( ) ;
113+ } ) ;
114+ } ) ;
115+ it ( 'subtracts a negative integer from a positive integer' , function ( done ) {
116+ request . get ( '/arithmetic?operation=subtract&operand1=21&operand2=-42' )
117+ . expect ( 200 )
118+ . end ( function ( err , res ) {
119+ expect ( res . body ) . to . eql ( { result : 63 } ) ;
120+ done ( ) ;
121+ } ) ;
122+ } ) ;
123+ it ( 'subtracts two negative integers' , function ( done ) {
124+ request . get ( '/arithmetic?operation=subtract&operand1=-21&operand2=-21' )
125+ . expect ( 200 )
126+ . end ( function ( err , res ) {
127+ expect ( res . body ) . to . eql ( { result : 0 } ) ;
128+ done ( ) ;
129+ } ) ;
130+ } ) ;
131+ it ( 'subtracts a floating point number from an integer' , function ( done ) {
132+ request . get ( '/arithmetic?operation=subtract&operand1=2.5&operand2=1.5' )
133+ . expect ( 200 )
134+ . end ( function ( err , res ) {
135+ expect ( res . body ) . to . eql ( { result : 1 } ) ;
136+ done ( ) ;
137+ } ) ;
138+ } ) ;
139+ it ( 'subtracts with negative exponent' , function ( done ) {
140+ request . get ( '/arithmetic?operation=subtract&operand1=1.2e-5&operand2=-1.2e-5' )
141+ . expect ( 200 )
142+ . end ( function ( err , res ) {
143+ expect ( res . body ) . to . eql ( { result : 2.4e-5 } ) ;
144+ done ( ) ;
145+ } ) ;
146+ } ) ;
147+ } ) ;
148+
99149 describe ( 'Multiplication' , function ( ) {
100150 it ( 'multiplies two positive integers' , function ( done ) {
101151 request . get ( '/arithmetic?operation=multiply&operand1=21&operand2=2' )
0 commit comments