@@ -255,6 +255,21 @@ describe('Query management', function () {
255255 should ( errorRaised ) . be . true ( ) ;
256256 } ) ;
257257
258+ it ( 'should discard the request if not connected and if queuing is deactivated' , function ( ) {
259+ var
260+ errorRaised = false ;
261+
262+ callback = ( ) => {
263+ errorRaised = true ;
264+ } ;
265+
266+ kuzzle . state = 'reconnecting' ;
267+ kuzzle . queuing = false ;
268+ kuzzle . query ( queryArgs , { body : { some : 'query' } } , callback ) ;
269+ should ( emitted ) . be . false ( ) ;
270+ should ( errorRaised ) . be . true ( ) ;
271+ } ) ;
272+
258273 it ( 'should queue the request during offline mode, if queuing has been activated' , function ( done ) {
259274 var
260275 query = { body : { some : 'query' } } ,
@@ -282,6 +297,33 @@ describe('Query management', function () {
282297 } ) ;
283298 } ) ;
284299
300+ it ( 'should queue the request during offline mode, if queuable is set to true' , function ( done ) {
301+ var
302+ query = { body : { some : 'query' } } ,
303+ cb = function ( ) { } ,
304+ now = Date . now ( ) ,
305+ eventFired = false ;
306+
307+ kuzzle . state = 'offline' ;
308+ kuzzle . queuing = false ;
309+ kuzzle . addListener ( 'offlineQueuePush' , object => {
310+ eventFired = true ;
311+ should ( object . query . body ) . be . eql ( query . body ) ;
312+ } ) ;
313+
314+ kuzzle . query ( queryArgs , query , { queuable : true } , cb ) ;
315+
316+ process . nextTick ( ( ) => {
317+ should ( emitted ) . be . false ( ) ;
318+ should ( kuzzle . offlineQueue . length ) . be . exactly ( 1 ) ;
319+ should ( kuzzle . offlineQueue [ 0 ] . ts ) . not . be . undefined ( ) . and . be . approximately ( now , 10 ) ;
320+ should ( kuzzle . offlineQueue [ 0 ] . query ) . match ( query ) ;
321+ should ( kuzzle . offlineQueue [ 0 ] . cb ) . be . exactly ( cb ) ;
322+ should ( eventFired ) . be . true ( ) ;
323+ done ( ) ;
324+ } ) ;
325+ } ) ;
326+
285327 it ( 'should queue the request if a queue filter has been defined and if it allows queuing' , function ( done ) {
286328 var
287329 query = { body : { some : 'query' } } ,
0 commit comments