File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,32 @@ describe('Server', function() {
91
91
} )
92
92
} )
93
93
94
+ describe ( 'GET /:resource?sort=' , function ( ) {
95
+ it ( 'should respond with json and sort on a field' , function ( done ) {
96
+ request ( server )
97
+ . get ( '/tags?_sort=body' )
98
+ . expect ( 'Content-Type' , / j s o n / )
99
+ . expect ( [ low . db . tags [ 1 ] , low . db . tags [ 0 ] , low . db . tags [ 2 ] ] )
100
+ . expect ( 200 , done )
101
+ } )
102
+
103
+ it ( 'should reverse sorting with sortDir=DESC' , function ( done ) {
104
+ request ( server )
105
+ . get ( '/tags?_sort=body&_sortDir=DESC' )
106
+ . expect ( 'Content-Type' , / j s o n / )
107
+ . expect ( [ low . db . tags [ 2 ] , low . db . tags [ 0 ] , low . db . tags [ 1 ] ] )
108
+ . expect ( 200 , done )
109
+ } )
110
+
111
+ it ( 'should sort on numerical field' , function ( done ) {
112
+ request ( server )
113
+ . get ( '/posts?_sort=id&_sortDir=DESC' )
114
+ . expect ( 'Content-Type' , / j s o n / )
115
+ . expect ( low . db . posts . reverse ( ) )
116
+ . expect ( 200 , done )
117
+ } )
118
+ } )
119
+
94
120
describe ( 'GET /:resource?_start=&_end=' , function ( ) {
95
121
it ( 'should respond with a sliced array' , function ( done ) {
96
122
request ( server )
You can’t perform that action at this time.
0 commit comments