@@ -20,10 +20,10 @@ describe('Users', () => {
2020 chai . request ( server )
2121 . get ( getAPI )
2222 . end ( ( err , res ) => {
23- res . should . have . status ( 401 ) ;
24- res . body . should . have . property ( 'success' ) . equal ( false ) ;
25- res . body . should . have . property ( 'message' ) . equal ( "Access Denied: Please supply login credentials!" ) ;
26- done ( ) ;
23+ res . should . have . status ( 401 ) ;
24+ res . body . should . have . property ( 'success' ) . equal ( false ) ;
25+ res . body . should . have . property ( 'message' ) . equal ( "Access Denied: Please supply login credentials!" ) ;
26+ done ( ) ;
2727 } ) ;
2828 } ) ;
2929 it ( 'should not GET if auth headers supplied are invalid' , ( done ) => {
@@ -35,21 +35,33 @@ describe('Users', () => {
3535 } ) ;
3636
3737 it ( 'should GET if auth headers are present' , ( done ) => {
38+ let user = {
39+ _id : "57029ed4795118be119cc437" ,
40+ fullName : "Joe Smith" ,
41+ emailAddress : "joe@smith.com" ,
42+ __v : 0
43+ } ;
44+
3845 let auth = {
3946 user : 'joe@smith.com' ,
4047 pass : 'password'
4148 } ;
42- getAuthRequest ( auth , 200 , true , "User Successfully retrieved" , done ) ;
49+ getAuthRequest ( auth , 200 , true , "User Successfully retrieved" , done , user ) ;
4350 } ) ;
4451
45- function getAuthRequest ( auth , status , success , msg , done ) {
52+ function getAuthRequest ( auth , status , success , msg , done , user ) {
4653 chai . request ( server )
4754 . get ( getAPI )
4855 . auth ( auth . user , auth . pass )
4956 . end ( ( err , res ) => {
5057 res . should . have . status ( status ) ;
5158 res . body . should . have . property ( 'success' ) . equal ( success ) ;
5259 res . body . should . have . property ( 'message' ) . equal ( msg ) ;
60+ if ( user ) {
61+ res . body . should . have . property ( 'user' ) . property ( 'fullName' ) . equal ( user . fullName ) ;
62+ res . body . should . have . property ( 'user' ) . property ( 'emailAddress' ) . equal ( user . emailAddress ) ;
63+ res . body . should . have . property ( 'user' ) . property ( '_id' ) . equal ( user . _id ) ;
64+ }
5365 done ( ) ;
5466 } ) ;
5567 }
@@ -94,9 +106,9 @@ describe('Users', () => {
94106 . post ( postAPI )
95107 . send ( user )
96108 . end ( ( err , res ) => {
97- res . body . should . have . property ( 'message' ) . equal ( "User Already Exists" ) ;
98- res . should . have . status ( 409 ) ; //Conflict error
99- done ( ) ;
109+ res . body . should . have . property ( 'message' ) . equal ( "User Already Exists" ) ;
110+ res . should . have . status ( 409 ) ; //Conflict error
111+ done ( ) ;
100112 } ) ;
101113 } ) ;
102114 } ) ;
@@ -126,7 +138,8 @@ describe('Users', () => {
126138 } ;
127139 postUser ( user , done ) ;
128140 } ) ;
129- function postUser ( user , done ) {
141+
142+ function postUser ( user , done ) {
130143 chai . request ( server )
131144 . post ( postAPI )
132145 . send ( user )
@@ -136,7 +149,8 @@ describe('Users', () => {
136149 done ( ) ;
137150 } ) ;
138151 }
139- function postUser400 ( user , done ) {
152+
153+ function postUser400 ( user , done ) {
140154 chai . request ( server )
141155 . post ( postAPI )
142156 . send ( user )
0 commit comments