@@ -3,6 +3,20 @@ describe('DS.findAll(resourceName, params[, options]): ', function () {
3
3
return 'DS.findAll(' + resourceName + ', params[, options]): ' ;
4
4
}
5
5
6
+ function createComments ( iterations ) {
7
+ var comments = [ ] ;
8
+ for ( var i = 1 ; i < iterations ; i ++ ) {
9
+ var comment = {
10
+ id : i
11
+ } ;
12
+ for ( var j = 1 ; j < 40 ; j ++ ) {
13
+ comment [ 'thing_' + j ] = 'test_content_' + j ;
14
+ }
15
+ comments . push ( comment ) ;
16
+ }
17
+ return comments ;
18
+ }
19
+
6
20
beforeEach ( startInjector ) ;
7
21
8
22
it ( 'should throw an error when method pre-conditions are not met' , function ( ) {
@@ -303,6 +317,124 @@ describe('DS.findAll(resourceName, params[, options]): ', function () {
303
317
fail ( 'Should not have failed!' ) ;
304
318
} ) ;
305
319
320
+ $httpBackend . flush ( ) ;
321
+ } ) ;
322
+ it ( 'stress test repeated injection' , function ( ) {
323
+ $httpBackend . expectGET ( 'http://test.angular-cache.com/comment' ) . respond ( 200 , createComments ( 100 ) ) ;
324
+
325
+ var start = new Date ( ) . getTime ( ) ;
326
+
327
+ DS . findAll ( 'comment' , { } , {
328
+ bypassCache : true
329
+ } ) . then ( function ( ) {
330
+ console . log ( '100 - time taken: ' + ( new Date ( ) . getTime ( ) - start ) + 'ms' ) ;
331
+ } , function ( ) {
332
+ fail ( 'Should not have failed!' ) ;
333
+ } ) ;
334
+
335
+ $httpBackend . flush ( ) ;
336
+
337
+ $httpBackend . expectGET ( 'http://test.angular-cache.com/comment' ) . respond ( 200 , createComments ( 100 ) ) ;
338
+
339
+ start = new Date ( ) . getTime ( ) ;
340
+
341
+ DS . findAll ( 'comment' , { } , {
342
+ bypassCache : true
343
+ } ) . then ( function ( ) {
344
+ console . log ( '100 - time taken: ' + ( new Date ( ) . getTime ( ) - start ) + 'ms' ) ;
345
+ } , function ( ) {
346
+ fail ( 'Should not have failed!' ) ;
347
+ } ) ;
348
+
349
+ $httpBackend . flush ( ) ;
350
+
351
+ $httpBackend . expectGET ( 'http://test.angular-cache.com/comment' ) . respond ( 200 , createComments ( 100 ) ) ;
352
+
353
+ start = new Date ( ) . getTime ( ) ;
354
+
355
+ DS . findAll ( 'comment' , { } , {
356
+ bypassCache : true
357
+ } ) . then ( function ( ) {
358
+ console . log ( '100 - time taken: ' + ( new Date ( ) . getTime ( ) - start ) + 'ms' ) ;
359
+ } , function ( ) {
360
+ fail ( 'Should not have failed!' ) ;
361
+ } ) ;
362
+
363
+ $httpBackend . flush ( ) ;
364
+ } ) ;
365
+ it ( 'stress test 1000' , function ( ) {
366
+ $httpBackend . expectGET ( 'http://test.angular-cache.com/comment' ) . respond ( 200 , createComments ( 1000 ) ) ;
367
+
368
+ var start = new Date ( ) . getTime ( ) ;
369
+
370
+ DS . findAll ( 'comment' , { } , {
371
+ bypassCache : true
372
+ } ) . then ( function ( ) {
373
+ console . log ( '1000 - time taken: ' + ( new Date ( ) . getTime ( ) - start ) + 'ms' ) ;
374
+ } , function ( ) {
375
+ fail ( 'Should not have failed!' ) ;
376
+ } ) ;
377
+
378
+ $httpBackend . flush ( ) ;
379
+ } ) ;
380
+ it ( 'stress test 2000' , function ( ) {
381
+ $httpBackend . expectGET ( 'http://test.angular-cache.com/comment' ) . respond ( 200 , createComments ( 2000 ) ) ;
382
+
383
+ var start = new Date ( ) . getTime ( ) ;
384
+
385
+ DS . findAll ( 'comment' , { } , {
386
+ bypassCache : true
387
+ } ) . then ( function ( ) {
388
+ console . log ( '2000 - time taken: ' + ( new Date ( ) . getTime ( ) - start ) + 'ms' ) ;
389
+ } , function ( ) {
390
+ fail ( 'Should not have failed!' ) ;
391
+ } ) ;
392
+
393
+ $httpBackend . flush ( ) ;
394
+ } ) ;
395
+ it ( 'stress test 3000' , function ( ) {
396
+ this . timeout ( 10000 ) ;
397
+ $httpBackend . expectGET ( 'http://test.angular-cache.com/comment' ) . respond ( 200 , createComments ( 3000 ) ) ;
398
+ var start = new Date ( ) . getTime ( ) ;
399
+
400
+ DS . findAll ( 'comment' , { } , {
401
+ bypassCache : true
402
+ } ) . then ( function ( ) {
403
+ console . log ( '3000 - time taken: ' + ( new Date ( ) . getTime ( ) - start ) + 'ms' ) ;
404
+ } , function ( ) {
405
+ fail ( 'Should not have failed!' ) ;
406
+ } ) ;
407
+
408
+ $httpBackend . flush ( ) ;
409
+ } ) ;
410
+ it ( 'stress test 4000' , function ( ) {
411
+ this . timeout ( 10000 ) ;
412
+ $httpBackend . expectGET ( 'http://test.angular-cache.com/comment' ) . respond ( 200 , createComments ( 4000 ) ) ;
413
+ var start = new Date ( ) . getTime ( ) ;
414
+
415
+ DS . findAll ( 'comment' , { } , {
416
+ bypassCache : true
417
+ } ) . then ( function ( ) {
418
+ console . log ( '4000 - time taken: ' + ( new Date ( ) . getTime ( ) - start ) + 'ms' ) ;
419
+ } , function ( ) {
420
+ fail ( 'Should not have failed!' ) ;
421
+ } ) ;
422
+
423
+ $httpBackend . flush ( ) ;
424
+ } ) ;
425
+ it ( 'stress test 5000' , function ( ) {
426
+ this . timeout ( 15000 ) ;
427
+ $httpBackend . expectGET ( 'http://test.angular-cache.com/comment' ) . respond ( 200 , createComments ( 5000 ) ) ;
428
+ var start = new Date ( ) . getTime ( ) ;
429
+
430
+ DS . findAll ( 'comment' , { } , {
431
+ bypassCache : true
432
+ } ) . then ( function ( ) {
433
+ console . log ( '5000 - time taken: ' + ( new Date ( ) . getTime ( ) - start ) + 'ms' ) ;
434
+ } , function ( ) {
435
+ fail ( 'Should not have failed!' ) ;
436
+ } ) ;
437
+
306
438
$httpBackend . flush ( ) ;
307
439
} ) ;
308
440
} ) ;
0 commit comments