diff --git a/test/integration/datastore/async_methods/findAll.test.js b/test/integration/datastore/async_methods/findAll.test.js index 8b64122..a112d22 100644 --- a/test/integration/datastore/async_methods/findAll.test.js +++ b/test/integration/datastore/async_methods/findAll.test.js @@ -3,6 +3,20 @@ describe('DS.findAll(resourceName, params[, options]): ', function () { return 'DS.findAll(' + resourceName + ', params[, options]): '; } + function createComments(iterations) { + var comments = []; + for (var i = 1; i < iterations; i++) { + var comment = { + id: i + }; + for (var j = 1; j < 40; j++) { + comment['thing_' + j] = 'test_content_' + j; + } + comments.push(comment); + } + return comments; + } + beforeEach(startInjector); it('should throw an error when method pre-conditions are not met', function () { @@ -303,6 +317,124 @@ describe('DS.findAll(resourceName, params[, options]): ', function () { fail('Should not have failed!'); }); + $httpBackend.flush(); + }); + it('stress test repeated injection', function () { + $httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(100)); + + var start = new Date().getTime(); + + DS.findAll('comment', {}, { + bypassCache: true + }).then(function () { + console.log('100 - time taken: ' + (new Date().getTime() - start) + 'ms'); + }, function () { + fail('Should not have failed!'); + }); + + $httpBackend.flush(); + + $httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(100)); + + start = new Date().getTime(); + + DS.findAll('comment', {}, { + bypassCache: true + }).then(function () { + console.log('100 - time taken: ' + (new Date().getTime() - start) + 'ms'); + }, function () { + fail('Should not have failed!'); + }); + + $httpBackend.flush(); + + $httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(100)); + + start = new Date().getTime(); + + DS.findAll('comment', {}, { + bypassCache: true + }).then(function () { + console.log('100 - time taken: ' + (new Date().getTime() - start) + 'ms'); + }, function () { + fail('Should not have failed!'); + }); + + $httpBackend.flush(); + }); + it('stress test 1000', function () { + $httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(1000)); + + var start = new Date().getTime(); + + DS.findAll('comment', {}, { + bypassCache: true + }).then(function () { + console.log('1000 - time taken: ' + (new Date().getTime() - start) + 'ms'); + }, function () { + fail('Should not have failed!'); + }); + + $httpBackend.flush(); + }); + it('stress test 2000', function () { + $httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(2000)); + + var start = new Date().getTime(); + + DS.findAll('comment', {}, { + bypassCache: true + }).then(function () { + console.log('2000 - time taken: ' + (new Date().getTime() - start) + 'ms'); + }, function () { + fail('Should not have failed!'); + }); + + $httpBackend.flush(); + }); + it('stress test 3000', function () { + this.timeout(10000); + $httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(3000)); + var start = new Date().getTime(); + + DS.findAll('comment', {}, { + bypassCache: true + }).then(function () { + console.log('3000 - time taken: ' + (new Date().getTime() - start) + 'ms'); + }, function () { + fail('Should not have failed!'); + }); + + $httpBackend.flush(); + }); + it('stress test 4000', function () { + this.timeout(10000); + $httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(4000)); + var start = new Date().getTime(); + + DS.findAll('comment', {}, { + bypassCache: true + }).then(function () { + console.log('4000 - time taken: ' + (new Date().getTime() - start) + 'ms'); + }, function () { + fail('Should not have failed!'); + }); + + $httpBackend.flush(); + }); + it('stress test 5000', function () { + this.timeout(15000); + $httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(5000)); + var start = new Date().getTime(); + + DS.findAll('comment', {}, { + bypassCache: true + }).then(function () { + console.log('5000 - time taken: ' + (new Date().getTime() - start) + 'ms'); + }, function () { + fail('Should not have failed!'); + }); + $httpBackend.flush(); }); });