@@ -134,5 +134,133 @@ export default (test) => {
134134 nestedFilterTest . only = testFilterOption . bind ( null , test . only ) ;
135135
136136 filterby ( nestedFilterTest ) ;
137+
138+ test ( '$orderby=Products(1) asc' , [ 1 ] , function ( result ) {
139+ it ( 'sort options are present on the result' , ( ) => {
140+ assert . notEqual ( result . options . $orderby , null ) ;
141+ } ) ;
142+ it ( 'sort options have a single property specified' , ( ) => {
143+ assert . equal ( result . options . $orderby . properties . length , 1 ) ;
144+ } ) ;
145+ it ( 'sort options property should be as expected' , ( ) => {
146+ assert . deepStrictEqual ( result . options . $orderby . properties , [
147+ {
148+ name : 'Products' ,
149+ key : { bind : 0 } ,
150+ order : 'asc' ,
151+ } ,
152+ ] ) ;
153+ } ) ;
154+ } ) ;
155+
156+ test ( '$orderby=Products(1)/Quantity asc' , [ 1 ] , function ( result ) {
157+ it ( 'sort options are present on the result' , ( ) => {
158+ assert . notEqual ( result . options . $orderby , null ) ;
159+ } ) ;
160+ it ( 'sort options have a single property specified' , ( ) => {
161+ assert . equal ( result . options . $orderby . properties . length , 1 ) ;
162+ } ) ;
163+ it ( 'sort options property should be as expected' , ( ) => {
164+ assert . deepStrictEqual ( result . options . $orderby . properties , [
165+ {
166+ name : 'Products' ,
167+ key : { bind : 0 } ,
168+ property : { name : 'Quantity' } ,
169+ order : 'asc' ,
170+ } ,
171+ ] ) ;
172+ } ) ;
173+ } ) ;
174+
175+ test (
176+ `$orderby=Products(partialkey='a')/Quantity asc` ,
177+ [ 'a' ] ,
178+ function ( result ) {
179+ it ( 'sort options are present on the result' , ( ) => {
180+ assert . notEqual ( result . options . $orderby , null ) ;
181+ } ) ;
182+ it ( 'sort options have a single property specified' , ( ) => {
183+ assert . equal ( result . options . $orderby . properties . length , 1 ) ;
184+ } ) ;
185+ it ( 'sort options property should be as expected' , ( ) => {
186+ assert . deepStrictEqual ( result . options . $orderby . properties , [
187+ {
188+ name : 'Products' ,
189+ key : {
190+ partialkey : { bind : 0 } ,
191+ } ,
192+ property : { name : 'Quantity' } ,
193+ order : 'asc' ,
194+ } ,
195+ ] ) ;
196+ } ) ;
197+ } ,
198+ ) ;
199+
200+ test ( '$orderby=Products(a=1,b=2)/Quantity asc' , [ 1 , 2 ] , function ( result ) {
201+ it ( 'sort options are present on the result' , ( ) => {
202+ assert . notEqual ( result . options . $orderby , null ) ;
203+ } ) ;
204+ it ( 'sort options have a single property specified' , ( ) => {
205+ assert . equal ( result . options . $orderby . properties . length , 1 ) ;
206+ } ) ;
207+ it ( 'sort options property should be as expected' , ( ) => {
208+ assert . deepStrictEqual ( result . options . $orderby . properties , [
209+ {
210+ name : 'Products' ,
211+ key : {
212+ a : { bind : 0 } ,
213+ b : { bind : 1 } ,
214+ } ,
215+ property : { name : 'Quantity' } ,
216+ order : 'asc' ,
217+ } ,
218+ ] ) ;
219+ } ) ;
220+ } ) ;
221+
222+ test ( `$orderby=Products(1)/Orders/$count asc` , [ 1 ] , function ( result ) {
223+ it ( 'sort options are present on the result' , ( ) => {
224+ assert . notEqual ( result . options . $orderby , null ) ;
225+ } ) ;
226+ it ( 'sort options have a single property specified' , ( ) => {
227+ assert . equal ( result . options . $orderby . properties . length , 1 ) ;
228+ } ) ;
229+ it ( 'sort options property should be as expected' , ( ) => {
230+ assert . deepStrictEqual ( result . options . $orderby . properties , [
231+ {
232+ name : 'Products' ,
233+ key : { bind : 0 } ,
234+ property : { name : 'Orders' , count : true , options : null } ,
235+ order : 'asc' ,
236+ } ,
237+ ] ) ;
238+ } ) ;
239+ } ) ;
240+
241+ test (
242+ `$orderby=Products(partialkey='a')/Orders/$count asc` ,
243+ [ 'a' ] ,
244+ function ( result ) {
245+ it ( 'sort options are present on the result' , ( ) => {
246+ assert . notEqual ( result . options . $orderby , null ) ;
247+ } ) ;
248+ it ( 'sort options have a single property specified' , ( ) => {
249+ assert . equal ( result . options . $orderby . properties . length , 1 ) ;
250+ } ) ;
251+ it ( 'sort options property should be as expected' , ( ) => {
252+ assert . deepStrictEqual ( result . options . $orderby . properties , [
253+ {
254+ name : 'Products' ,
255+ key : {
256+ partialkey : { bind : 0 } ,
257+ } ,
258+ property : { name : 'Orders' , count : true , options : null } ,
259+ order : 'asc' ,
260+ } ,
261+ ] ) ;
262+ } ) ;
263+ } ,
264+ ) ;
137265 } ) ;
138266} ;
0 commit comments