@@ -76,17 +76,20 @@ describe("Query Tests", () => {
7676 it ( 'should return the meta content for a query' , ( ) => {
7777 return queries . getReviews ( 1 , 5 , undefined , 12345 )
7878 . then ( response => {
79- assert . propertyVal ( response , 'product' , 12345 ) ;
80- assert . propertyVal ( response , 'page' , 1 ) ;
81- assert . propertyVal ( response , 'count' , 5 ) ;
82- assert . exists ( response . results ) ;
79+ assert . propertyVal ( response , 'status' , 200 ) ;
80+ assert . propertyVal ( response , 'message' , 'OK' ) ;
81+ const data = response . data ;
82+ assert . propertyVal ( data , 'product' , 12345 ) ;
83+ assert . propertyVal ( data , 'page' , 1 ) ;
84+ assert . propertyVal ( data , 'count' , 5 ) ;
85+ assert . exists ( data . results ) ;
8386 } ) ;
8487 } ) ;
8588
8689 it ( 'should get entries for a given product_id that include photo entries' , ( ) => {
8790 return queries . getReviews ( '1' , '5' , undefined , '12' )
8891 . then ( response => {
89- const results = response . results ;
92+ const results = response . data . results ;
9093 assert . lengthOf ( results , 3 ) ;
9194 assert . propertyVal ( results [ 0 ] , 'reviewer_name' , 'Sallie_Kovacek' ) ;
9295 assert . isArray ( results [ 0 ] . photos ) ;
@@ -99,7 +102,7 @@ describe("Query Tests", () => {
99102 it ( 'should organize entries by newest' , ( ) => {
100103 return queries . getReviews ( '1' , '5' , 'newest' , '12' )
101104 . then ( response => {
102- const results = response . results ;
105+ const results = response . data . results ;
103106 assert . lengthOf ( results , 3 ) ;
104107 assert . propertyVal ( results [ 0 ] , 'reviewer_name' , 'Curtis_King46' ) ;
105108 assert . propertyVal ( results [ 1 ] , 'reviewer_name' , 'Sallie_Kovacek' ) ;
@@ -110,7 +113,7 @@ describe("Query Tests", () => {
110113 it ( 'should organize entries by helpful' , ( ) => {
111114 return queries . getReviews ( '1' , '5' , 'helpful' , '12' )
112115 . then ( response => {
113- const results = response . results ;
116+ const results = response . data . results ;
114117 assert . lengthOf ( results , 3 ) ;
115118 assert . propertyVal ( results [ 0 ] , 'reviewer_name' , 'Kip.Streich' ) ;
116119 assert . propertyVal ( results [ 1 ] , 'reviewer_name' , 'Curtis_King46' ) ;
@@ -121,7 +124,7 @@ describe("Query Tests", () => {
121124 it ( 'should organize entries by relevant' , ( ) => {
122125 return queries . getReviews ( '1' , '5' , 'relevant' , '12' )
123126 . then ( response => {
124- const results = response . results ;
127+ const results = response . data . results ;
125128 assert . lengthOf ( results , 3 ) ;
126129 assert . propertyVal ( results [ 0 ] , 'reviewer_name' , 'Kip.Streich' ) ;
127130 assert . propertyVal ( results [ 1 ] , 'reviewer_name' , 'Curtis_King46' ) ;
@@ -132,8 +135,8 @@ describe("Query Tests", () => {
132135 it ( 'should return an empty array when no entries exist at a given product_id' , ( ) => {
133136 return queries . getReviews ( '1' , '5' , undefined , '0' )
134137 . then ( response => {
135- assert . isArray ( response . results ) ;
136- assert . lengthOf ( response . results , 0 ) ;
138+ assert . isArray ( response . data . results ) ;
139+ assert . lengthOf ( response . data . results , 0 ) ;
137140 } ) ;
138141 } ) ;
139142 } ) ;
@@ -152,49 +155,55 @@ describe("Query Tests", () => {
152155 it ( 'should return the meta content for a query' , ( ) => {
153156 return queries . getReviewsMeta ( 12345 )
154157 . then ( response => {
155- assert . propertyVal ( response , 'product_id' , 12345 ) ;
158+ assert . propertyVal ( response , 'status' , 200 ) ;
159+ assert . propertyVal ( response , 'message' , 'OK' ) ;
160+ assert . exists ( response . data ) ;
156161 } ) ;
157162 } ) ;
158163
159164 it ( 'should get an entry for a given product_id that includes multiple characteristics' , ( ) => {
160165 return queries . getReviewsMeta ( 12 )
161166 . then ( response => {
162- assert . isObject ( response . ratings ) ;
163- assert . isObject ( response . recommended ) ;
164- assert . isObject ( response . characteristics ) ;
165- assert . lengthOf ( Object . keys ( response . characteristics ) , 4 ) ;
167+ const data = response . data ;
168+ assert . isObject ( data . ratings ) ;
169+ assert . isObject ( data . recommended ) ;
170+ assert . isObject ( data . characteristics ) ;
171+ assert . lengthOf ( Object . keys ( data . characteristics ) , 4 ) ;
166172 } ) ;
167173 } ) ;
168174
169175 it ( 'should collate ratings into ratings object' , ( ) => {
170176 return queries . getReviewsMeta ( 12 )
171177 . then ( response => {
172- assert . propertyVal ( response . ratings , "4" , 2 ) ;
173- assert . propertyVal ( response . ratings , "2" , 1 ) ;
178+ const data = response . data ;
179+ assert . propertyVal ( data . ratings , "4" , 2 ) ;
180+ assert . propertyVal ( data . ratings , "2" , 1 ) ;
174181 } ) ;
175182 } ) ;
176183
177184 it ( 'should collate recommend values into recommended object' , ( ) => {
178185 return queries . getReviewsMeta ( 12 )
179186 . then ( response => {
180- assert . propertyVal ( response . recommended , "1" , 2 ) ;
181- assert . propertyVal ( response . recommended , "0" , 1 ) ;
187+ const data = response . data ;
188+ assert . propertyVal ( data . recommended , "1" , 2 ) ;
189+ assert . propertyVal ( data . recommended , "0" , 1 ) ;
182190 } ) ;
183191 } ) ;
184192
185193 it ( 'should collate all characteristics and average their values' , ( ) => {
186194 return queries . getReviewsMeta ( 12 )
187195 . then ( response => {
188- assert . containsAllKeys ( response . characteristics , [
196+ const data = response . data ;
197+ assert . containsAllKeys ( data . characteristics , [
189198 "Fit" ,
190199 "Length" ,
191200 "Comfort" ,
192201 "Quality"
193202 ] ) ;
194- assert . equal ( response . characteristics [ "Fit" ] . value , ( 2 + 2 ) / 2 ) ;
195- assert . equal ( response . characteristics [ "Length" ] . value , ( 2 + 1 ) / 2 ) ;
196- assert . equal ( response . characteristics [ "Comfort" ] . value , ( 2 + 4 ) / 2 ) ;
197- assert . equal ( response . characteristics [ "Quality" ] . value , ( 4 + 3 ) / 2 ) ;
203+ assert . equal ( data . characteristics [ "Fit" ] . value , ( 2 + 2 ) / 2 ) ;
204+ assert . equal ( data . characteristics [ "Length" ] . value , ( 2 + 1 ) / 2 ) ;
205+ assert . equal ( data . characteristics [ "Comfort" ] . value , ( 2 + 4 ) / 2 ) ;
206+ assert . equal ( data . characteristics [ "Quality" ] . value , ( 4 + 3 ) / 2 ) ;
198207 } ) ;
199208 } ) ;
200209 } ) ;
@@ -226,7 +235,10 @@ describe("Query Tests", () => {
226235 "42" : 4 ,
227236 "41" : 2
228237 } ,
229- } ) . then ( status => assert . equal ( status , 200 ) )
238+ } ) . then ( response => {
239+ assert . propertyVal ( response , 'status' , 201 ) ;
240+ assert . propertyVal ( response , 'message' , 'CREATED' ) ;
241+ } )
230242 . then ( ( ) => {
231243 const query = Review . findOne ( ) . sort ( { id : - 1 } ) ;
232244 return query . lean ( ) . exec ( ) ;
@@ -281,7 +293,10 @@ describe("Query Tests", () => {
281293 return Review . findOne ( { id : 2 } )
282294 . then ( review => assert . propertyVal ( review , 'helpfulness' , 2 ) )
283295 . then ( ( ) => queries . putReviewHelpful ( '2' ) )
284- . then ( status => assert . equal ( status , 204 ) )
296+ . then ( response => {
297+ assert . propertyVal ( response , 'status' , 204 ) ;
298+ assert . propertyVal ( response , 'message' , 'NO CONTENT' ) ;
299+ } )
285300 . then ( ( ) => {
286301 const query = Review . findOne ( { id : 2 } ) ;
287302 return query . lean ( ) . exec ( ) ;
@@ -310,7 +325,10 @@ describe("Query Tests", () => {
310325 return Review . findOne ( { id : 2 } )
311326 . then ( review => assert . propertyVal ( review , 'reported' , false ) )
312327 . then ( ( ) => queries . putReviewReport ( '2' ) )
313- . then ( status => assert . equal ( status , 204 ) )
328+ . then ( response => {
329+ assert . propertyVal ( response , 'status' , 204 ) ;
330+ assert . propertyVal ( response , 'message' , 'NO CONTENT' ) ;
331+ } )
314332 . then ( ( ) => {
315333 const query = Review . findOne ( { id : 2 } ) ;
316334 return query . lean ( ) . exec ( ) ;
@@ -324,7 +342,6 @@ describe("Query Tests", () => {
324342 return Review . findOne ( { id : 18 } )
325343 . then ( review => assert . propertyVal ( review , 'reported' , true ) )
326344 . then ( ( ) => queries . putReviewReport ( '18' ) )
327- . then ( status => assert . equal ( status , 204 ) )
328345 . then ( ( ) => {
329346 const query = Review . findOne ( { id : 18 } ) ;
330347 return query . lean ( ) . exec ( ) ;
0 commit comments