@@ -251,6 +251,57 @@ describe('loopback json api component find methods', function () {
251251 } )
252252 } )
253253 } )
254+ describe ( 'Paging should filter' , function ( ) {
255+ beforeEach ( function ( done ) {
256+ Post . create ( {
257+ title : 'deer can jump' ,
258+ content : 'deer can jump really high in their natural habitat'
259+ } , function ( ) {
260+ Post . create ( {
261+ title : 'pigs dont fly' ,
262+ content : "contrary to the myth, pigs don't fly!"
263+ } , function ( ) {
264+ Post . create ( {
265+ title : 'unicorns come from rainbows' ,
266+ content : 'at the end of a rainbow may be a pot of gold, but also a mythical unicorn'
267+ } , done )
268+ } )
269+ } )
270+ } )
271+
272+ it ( 'should filter only one' , function ( done ) {
273+ request ( app )
274+ . get ( '/posts?page[limit]=1' )
275+ . expect ( 200 )
276+ . end ( function ( err , res ) {
277+ expect ( err ) . to . equal ( null )
278+ expect ( res . body . data . length ) . to . equal ( 1 )
279+ done ( )
280+ } )
281+ } )
282+
283+ it ( 'should filter two' , function ( done ) {
284+ request ( app )
285+ . get ( '/posts?page[limit]=2' )
286+ . expect ( 200 )
287+ . end ( function ( err , res ) {
288+ expect ( err ) . to . equal ( null )
289+ expect ( res . body . data . length ) . to . equal ( 2 )
290+ done ( )
291+ } )
292+ } )
293+
294+ it ( 'should skip first' , function ( done ) {
295+ request ( app )
296+ . get ( '/posts?page[limit]=1&page[offset]=1' )
297+ . expect ( 200 )
298+ . end ( function ( err , res ) {
299+ expect ( res . body . data . length ) . to . equal ( 1 )
300+ expect ( res . body . data [ 0 ] . id ) . to . equal ( '2' )
301+ done ( )
302+ } )
303+ } )
304+ } )
254305} )
255306
256307describe ( 'non standard primary key naming' , function ( ) {
0 commit comments