@@ -28,17 +28,19 @@ const configuration = {
2828describe ( 'getSubmissions' , ( ) => {
2929 const state = { configuration } ;
3030 const sampleData = [
31- { uid : '1' , name : 'Ruh' } ,
32- { uid : '2' , name : 'Shay' } ,
31+ { uid : '1' , name : 'Bob' } ,
32+ { uid : '4' , name : 'Anuh' } ,
33+ { uid : '3' , name : 'Charlie' } ,
3334 ] ;
35+
3436 let originalLog ;
3537 let consoleOutput = [ ] ;
3638 beforeEach ( ( ) => {
3739 originalLog = console . warn ;
3840 console . warn = ( ...args ) => consoleOutput . push ( ...args ) ;
3941 } ) ;
4042
41- it . only ( 'should sort items by uid in descending order' , async ( ) => {
43+ it ( 'should sort items by uid in descending order' , async ( ) => {
4244 testServer
4345 . intercept ( {
4446 path : / \/ a p i \/ v 2 \/ a s s e t s \/ a X e c H j m b A T u F 6 i G F m v B L B X \/ d a t a / ,
@@ -53,6 +55,7 @@ describe('getSubmissions', () => {
5355 {
5456 limit : query . limit ,
5557 start : query . start ,
58+ sort : query . sort ,
5659 } ,
5760 {
5861 url : `${ origin } ${ path } ` ,
@@ -68,8 +71,39 @@ describe('getSubmissions', () => {
6871 const { data } = await getSubmissions ( 'aXecHjmbATuF6iGFmvBLBX' , {
6972 sort : { uid : - 1 } ,
7073 } ) ( state ) ;
71- console . log ( { data } ) ;
72- expect ( data [ 0 ] . uid ) . to . eql ( '2' ) ;
74+
75+ expect ( data [ 0 ] . uid ) . to . eql ( '4' ) ;
76+ } ) ;
77+ it ( 'should start from the specified index' , async ( ) => {
78+ testServer
79+ . intercept ( {
80+ path : / \/ a p i \/ v 2 \/ a s s e t s \/ a X e c H j m b A T u F 6 i G F m v B L B X \/ d a t a / ,
81+ method : 'GET' ,
82+ } )
83+ . reply (
84+ 200 ,
85+ req => {
86+ const { query, origin, path } = req ;
87+ const results = responseWithPagination (
88+ sampleData ,
89+ {
90+ limit : query . limit ,
91+ start : query . start ,
92+ } ,
93+ {
94+ url : `${ origin } ${ path } ` ,
95+ }
96+ ) ;
97+ return results ;
98+ } ,
99+ {
100+ ...jsonHeaders ,
101+ }
102+ ) ;
103+ const { data } = await getSubmissions ( 'aXecHjmbATuF6iGFmvBLBX' , {
104+ start : 2 ,
105+ } ) ( state ) ;
106+ expect ( data [ 0 ] . uid ) . to . eql ( '3' ) ;
73107 } ) ;
74108 it ( 'should not return more items than the default limit' , async ( ) => {
75109 let requestCount = 0 ;
0 commit comments