@@ -42,7 +42,9 @@ describe('Auctions', function () {
42
42
. request ( app )
43
43
. get ( '/auctions' )
44
44
. end ( ( err , res ) => {
45
- if ( err ) { return done ( err ) }
45
+ if ( err ) {
46
+ return done ( err )
47
+ }
46
48
47
49
expect ( res ) . to . have . status ( 200 )
48
50
expect ( res . body ) . to . be . a ( 'object' )
@@ -61,12 +63,24 @@ describe('Auctions', function () {
61
63
. request ( app )
62
64
. get ( `/auctions/${ auctionId } ` )
63
65
. end ( ( err , res ) => {
64
- if ( err ) { return done ( err ) }
66
+ if ( err ) {
67
+ return done ( err )
68
+ }
65
69
66
70
expect ( res ) . to . have . status ( 200 )
67
71
expect ( res . body ) . to . be . a ( 'object' )
68
72
expect ( res . body ) . to . have . all . keys ( ...auctionWithIdKeys )
73
+ expect ( res . body . item ) . to . be . a ( 'string' )
74
+ expect ( res . body . quantity ) . to . be . a ( 'number' )
75
+ expect ( res . body . end_time ) . to . be . a ( 'number' )
76
+ expect ( res . body . highest_bid ) . to . be . a ( 'number' )
77
+ expect ( res . body . start_time ) . to . be . a ( 'number' )
78
+ expect ( res . body . bidders_and_bids ) . to . be . a ( 'array' )
69
79
expect ( res . body . seller ) . to . be . equal ( userData [ 0 ] . username )
80
+ expect ( res . body . item ) . to . be . equal ( auctionData . item_type )
81
+ expect ( res . body . quantity ) . to . be . equal ( auctionData . quantity )
82
+ expect ( res . body . end_time ) . to . be . equal ( auctionData . end_time )
83
+ expect ( res . body . highest_bid ) . to . be . equal ( auctionData . initial_price )
70
84
71
85
return done ( )
72
86
} )
@@ -77,7 +91,9 @@ describe('Auctions', function () {
77
91
. request ( app )
78
92
. get ( '/auctions/invalidId' )
79
93
. end ( ( err , res ) => {
80
- if ( err ) { return done ( err ) }
94
+ if ( err ) {
95
+ return done ( err )
96
+ }
81
97
82
98
expect ( res ) . to . have . status ( 404 )
83
99
expect ( res . body ) . to . be . a ( 'object' )
@@ -96,7 +112,9 @@ describe('Auctions', function () {
96
112
. set ( 'cookie' , `${ cookieName } =${ jwt } ` )
97
113
. send ( auctionData )
98
114
. end ( ( err , res ) => {
99
- if ( err ) { return done ( err ) }
115
+ if ( err ) {
116
+ return done ( err )
117
+ }
100
118
101
119
expect ( res ) . to . have . status ( 201 )
102
120
expect ( res . body ) . to . be . a ( 'object' )
@@ -106,14 +124,16 @@ describe('Auctions', function () {
106
124
} )
107
125
} )
108
126
109
- it ( 'Should have enough Item Type in wallet' , function ( done ) {
127
+ it ( 'User should have enough items in wallet to sell ' , function ( done ) {
110
128
chai
111
129
. request ( app )
112
130
. post ( '/auctions' )
113
131
. set ( 'cookie' , `${ cookieName } =${ jwt } ` )
114
132
. send ( { ...auctionData , quantity : 5 } )
115
133
. end ( ( err , res ) => {
116
- if ( err ) { return done ( err ) }
134
+ if ( err ) {
135
+ return done ( err )
136
+ }
117
137
118
138
expect ( res ) . to . have . status ( 403 )
119
139
expect ( res . body ) . to . be . a ( 'object' )
@@ -128,7 +148,9 @@ describe('Auctions', function () {
128
148
. request ( app )
129
149
. post ( '/auctions' )
130
150
. end ( ( err , res ) => {
131
- if ( err ) { return done ( err ) }
151
+ if ( err ) {
152
+ return done ( err )
153
+ }
132
154
133
155
expect ( res ) . to . have . status ( 401 )
134
156
expect ( res . body ) . to . be . a ( 'object' )
@@ -151,7 +173,9 @@ describe('Auctions', function () {
151
173
. set ( 'cookie' , `${ cookieName } =${ jwt } ` )
152
174
. send ( { bid : 500 } )
153
175
. end ( ( err , res ) => {
154
- if ( err ) { return done ( err ) }
176
+ if ( err ) {
177
+ return done ( err )
178
+ }
155
179
156
180
expect ( res ) . to . have . status ( 201 )
157
181
expect ( res . body ) . to . be . a ( 'object' )
@@ -161,15 +185,17 @@ describe('Auctions', function () {
161
185
} )
162
186
} )
163
187
164
- it ( 'Should have a sufficient balance' , function ( done ) {
188
+ it ( 'User should have sufficient balance for bidding ' , function ( done ) {
165
189
chai
166
190
. request ( app )
167
191
. post ( `/auctions/bid/${ auctionId } ` )
168
192
. set ( 'cookie' , `${ cookieName } =${ jwt } ` )
169
193
. send ( { bid : 1001 } )
170
194
171
195
. end ( ( err , res ) => {
172
- if ( err ) { return done ( err ) }
196
+ if ( err ) {
197
+ return done ( err )
198
+ }
173
199
174
200
expect ( res ) . to . have . status ( 403 )
175
201
expect ( res . body ) . to . be . a ( 'object' )
@@ -179,14 +205,16 @@ describe('Auctions', function () {
179
205
} )
180
206
} )
181
207
182
- it ( 'Should be higher than the previous bid' , function ( done ) {
208
+ it ( 'Bid Should be higher than the previous bid' , function ( done ) {
183
209
chai
184
210
. request ( app )
185
211
. post ( `/auctions/bid/${ auctionId } ` )
186
212
. set ( 'cookie' , `${ cookieName } =${ jwt } ` )
187
213
. send ( { bid : 50 } )
188
214
. end ( ( err , res ) => {
189
- if ( err ) { return done ( err ) }
215
+ if ( err ) {
216
+ return done ( err )
217
+ }
190
218
191
219
expect ( res ) . to . have . status ( 403 )
192
220
expect ( res . body ) . to . be . a ( 'object' )
@@ -201,7 +229,9 @@ describe('Auctions', function () {
201
229
. request ( app )
202
230
. post ( '/auctions/bid/invalidId' )
203
231
. end ( ( err , res ) => {
204
- if ( err ) { return done ( err ) }
232
+ if ( err ) {
233
+ return done ( err )
234
+ }
205
235
206
236
expect ( res ) . to . have . status ( 401 )
207
237
expect ( res . body ) . to . be . a ( 'object' )
0 commit comments