@@ -109,7 +109,7 @@ module.exports = () => {
109109
110110 it ( 'should support pagination, offset 0 and limit 1' , ( done ) => {
111111 request ( server )
112- . get ( '/api/logs?page[offset]=0&page[limit]=1' )
112+ . get ( '/api/logs?page[offset]=0&page[limit]=1&sort=id ' )
113113 . expect ( 200 )
114114 . end ( ( err , res ) => {
115115 if ( err ) {
@@ -129,7 +129,7 @@ module.exports = () => {
129129
130130 it ( 'should support pagination, offset 1 and limit 1' , ( done ) => {
131131 request ( server )
132- . get ( '/api/logs?page[offset]=1&page[limit]=1' )
132+ . get ( '/api/logs?page[offset]=1&page[limit]=1&sort=id ' )
133133 . expect ( 200 )
134134 . end ( ( err , res ) => {
135135 if ( err ) {
@@ -167,6 +167,46 @@ module.exports = () => {
167167 done ( ) ;
168168 } ) ;
169169 } ) ;
170+
171+ it ( 'should support sorting, id DESC' , ( done ) => {
172+ request ( server )
173+ . get ( '/api/logs?sort=-id' )
174+ . expect ( 200 )
175+ . end ( ( err , res ) => {
176+ if ( err ) {
177+ done ( err ) ;
178+ return ;
179+ }
180+
181+ // Response must satisfy the OpenAPI specification
182+ expect ( res ) . to . satisfyApiSpec ;
183+
184+ const { data } = res . body ;
185+ expect ( data [ 0 ] . entryId ) . to . be . greaterThan ( data [ 1 ] . entryId ) ;
186+
187+ done ( ) ;
188+ } ) ;
189+ } ) ;
190+
191+ it ( 'should support sorting, id ASC' , ( done ) => {
192+ request ( server )
193+ . get ( '/api/logs?sort=id' )
194+ . expect ( 200 )
195+ . end ( ( err , res ) => {
196+ if ( err ) {
197+ done ( err ) ;
198+ return ;
199+ }
200+
201+ // Response must satisfy the OpenAPI specification
202+ expect ( res ) . to . satisfyApiSpec ;
203+
204+ const { data } = res . body ;
205+ expect ( data [ 1 ] . entryId ) . to . be . greaterThan ( data [ 0 ] . entryId ) ;
206+
207+ done ( ) ;
208+ } ) ;
209+ } ) ;
170210 } ) ;
171211
172212 describe ( 'POST /api/logs' , ( ) => {
0 commit comments