@@ -140,115 +140,6 @@ describe("GET volunteer", function () {
140140
141141} ) ;
142142
143- describe ( "GET volunteer" , function ( ) {
144- it ( "should FAIL to get volunteer due to lack of authentication" , function ( done ) {
145- chai . request ( server . app )
146- . get ( `/api/volunteer/${ util . volunteer . Volunteer1 . _id } ` )
147- . end ( function ( err , res ) {
148- res . should . have . status ( 401 ) ;
149- res . should . be . json ;
150- res . body . should . have . property ( "message" ) ;
151- res . body . message . should . equal ( Constants . Error . AUTH_401_MESSAGE ) ;
152- res . body . should . have . property ( "data" ) ;
153-
154- done ( ) ;
155- } ) ;
156- } ) ;
157-
158- it ( "should Fail to GET volunteer due inappropriate authorization" , function ( done ) {
159- util . auth . login ( agent , util . account . Hacker5 , ( error ) => {
160- if ( error ) {
161- agent . close ( ) ;
162- return done ( error ) ;
163- }
164- return agent
165- . get ( `/api/volunteer/${ util . volunteer . Volunteer1 . _id } ` )
166- . end ( function ( err , res ) {
167- res . should . have . status ( 403 ) ;
168- res . should . be . json ;
169- res . body . should . have . property ( "message" ) ;
170- res . body . message . should . equal ( Constants . Error . AUTH_403_MESSAGE ) ;
171- res . body . should . have . property ( "data" ) ;
172-
173- done ( ) ;
174- } ) ;
175- } ) ;
176- } ) ;
177-
178- it ( "should Fail to GET volunteer due to non existant volunteer id" , function ( done ) {
179- util . auth . login ( agent , util . account . Admin1 , ( error ) => {
180- if ( error ) {
181- agent . close ( ) ;
182- return done ( error ) ;
183- }
184- return agent
185- . get ( `/api/volunteer/${ util . account . Admin1 . _id } ` )
186- . end ( function ( err , res ) {
187- res . should . have . status ( 404 ) ;
188- res . should . be . json ;
189- res . body . should . have . property ( "message" ) ;
190- res . body . message . should . equal ( Constants . Error . VOLUNTEER_404_MESSAGE ) ;
191- res . body . should . have . property ( "data" ) ;
192-
193- done ( ) ;
194- } ) ;
195- } ) ;
196- } ) ;
197-
198- // success case
199- it ( "should GET volunteer info by id with admin credentials" , function ( done ) {
200- util . auth . login ( agent , util . account . Admin1 , ( error ) => {
201- if ( error ) {
202- agent . close ( ) ;
203- return done ( error ) ;
204- }
205- return agent
206- . get ( `/api/volunteer/${ util . volunteer . Volunteer1 . _id } ` )
207- . end ( function ( err , res ) {
208- if ( err ) {
209- return done ( err ) ;
210- }
211- res . should . have . status ( 200 ) ;
212- res . should . be . json ;
213- res . body . should . have . property ( "message" ) ;
214- res . body . message . should . equal ( Constants . Success . VOLUNTEER_GET_BY_ID ) ;
215- res . body . should . have . property ( "data" ) ;
216-
217- let volunteer = new Volunteer ( util . volunteer . Volunteer1 ) ;
218- chai . assert . equal ( JSON . stringify ( res . body . data ) , JSON . stringify ( volunteer . toJSON ( ) ) ) ;
219- done ( ) ;
220- } ) ;
221- } ) ;
222- } ) ;
223-
224- // success case
225- it ( "should GET the user's volunteer info by id" , function ( done ) {
226- util . auth . login ( agent , util . account . Account4 , ( error ) => {
227- if ( error ) {
228- agent . close ( ) ;
229- return done ( error ) ;
230- }
231- return agent
232- . get ( `/api/volunteer/${ util . volunteer . Volunteer1 . _id } ` )
233- . end ( function ( err , res ) {
234- if ( err ) {
235- return done ( err ) ;
236- }
237- res . should . have . status ( 200 ) ;
238- res . should . be . json ;
239- res . body . should . have . property ( "message" ) ;
240- res . body . message . should . equal ( Constants . Success . VOLUNTEER_GET_BY_ID ) ;
241- res . body . should . have . property ( "data" ) ;
242-
243- let volunteer = new Volunteer ( util . volunteer . Volunteer1 ) ;
244- chai . assert . equal ( JSON . stringify ( res . body . data ) , JSON . stringify ( volunteer . toJSON ( ) ) ) ;
245- done ( ) ;
246- } ) ;
247- } ) ;
248- } ) ;
249-
250- } ) ;
251-
252143describe ( "POST create volunteer" , function ( ) {
253144 it ( "should fail to create a new volunteer due to lack of authentication" , function ( done ) {
254145 chai . request ( server . app )
0 commit comments