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