How to use expectEmpty method in ng-mocks

Best JavaScript code snippet using ng-mocks

Range.js

Source:Range.js Github

copy

Full Screen

...111 }112 113 expect(pass).toBe(true);114 }115 function expectEmpty(begin, end) {116 var records = range.records,117 pass = true,118 i;119 for (i = begin; i < end; ++i) {120 if (records[i]) {121 pass = false;122 break;123 }124 }125 126 expect(pass).toBe(true);127 }128 function makePageRange(start, end) {129 var pages = [],130 reverse = start > end,131 i;132 if (reverse) {133 i = start;134 start = end;135 end = i;136 }137 for (i = start; i <= end; ++i) {138 pages.push(i);139 }140 if (reverse) {141 pages.reverse();142 }143 return pages;144 }145 beforeEach(function() {146 total = 100000;147 pageSize = 25;148 MockAjaxManager.addMethods();149 callbackSpy = jasmine.createSpy();150 makeStore();151 });152 afterEach(function() {153 MockAjaxManager.removeMethods();154 total = pageSize = proxySpy = callbackSpy = pageMap = range = store = Ext.destroy(store);155 });156 function expectRangeSize(begin, end) {157 expect(range.begin).toBe(begin);158 expect(range.end).toBe(end);159 expect(range.length).toBe(end - begin);160 }161 describe("without prefetching", function() {162 function makeRange(cfg) {163 range = store.createActiveRange(Ext.apply({164 delay: 0,165 callback: callbackSpy166 }, cfg));167 }168 describe("construction", function() {169 it("should not alter the range, or make any requests", function() {170 makeRange();171 expectRangeSize(0, 0);172 flushNextLoad();173 expect(proxySpy).not.toHaveBeenCalled();174 });175 it("should make data requests if begin was specified", function() {176 makeRange({177 begin: 0,178 end: 100179 });180 expectRangeSize(0, 100);181 flushAllLoads();182 expect(proxySpy.callCount).toBe(4);183 });184 });185 describe("basic loading functionality", function() {186 beforeEach(function() {187 makeRange();188 });189 describe("pageSize", function() {190 it("should use the store page size", function() {191 store.setPageSize(50);192 range.goto(0, 100);193 flushAllLoads();194 expectProxyPages([1, 2]);195 expectCallbacks([[0, 50], [50, 100]]);196 expectRecords(0, 100);197 });198 });199 describe("range constraints", function() {200 describe("total not known", function() {201 it("should allow for any size load", function() {202 range.goto(total * 2, total * 2 + pageSize * 4);203 expectRangeSize(total * 2, total * 2 + pageSize * 4);204 flushAllLoads();205 expectProxyPages([8001]);206 expect(callbackSpy).not.toHaveBeenCalled();207 });208 });209 describe("total known", function() {210 it("should raise an exception if passing a known count", function() {211 range.goto(0, 100);212 flushAllLoads();213 proxySpy.reset();214 callbackSpy.reset();215 expect(function() {216 range.goto(total * 2, total * 2 + pageSize);217 }).toThrow();218 flushAllLoads();219 expect(proxySpy).not.toHaveBeenCalled();220 expect(callbackSpy).not.toHaveBeenCalled();221 });222 });223 });224 describe("range smaller than the page size", function() {225 describe("range falls within a single page", function() {226 it("should fulfil at the start of the dataset", function() {227 range.goto(10, 20);228 expectRangeSize(10, 20);229 flushAllLoads();230 expectProxyPages([1]);231 expectRecords(0, 25);232 expectEmpty(25, 100);233 expectCallbacks([[10, 20]]);234 });235 it("should fulfil in the middle of the dataset", function() {236 range.goto(20005, 20015);237 expectRangeSize(20005, 20015);238 flushAllLoads();239 expectProxyPages([801]);240 expectRecords(20000, 20025);241 expectEmpty(19900, 20000);242 expectEmpty(20025, 20100);243 expectCallbacks([[20005, 20015]]);244 });245 it("should fulfil at the end of the dataset", function() {246 range.goto(99980, 99990);247 expectRangeSize(99980, 99990);248 flushAllLoads();249 expectProxyPages([4000]);250 expectRecords(99975, 100000);251 expectEmpty(99900, 99975);252 expectCallbacks([[99980, 99990]]);253 });254 });255 describe("range covers multiple pages", function() {256 it("should fulfil at the start of the dataset", function() {257 range.goto(20, 30);258 expectRangeSize(20, 30);259 flushAllLoads();260 expectProxyPages([1, 2]);261 expectRecords(0, 50);262 expectEmpty(50, 100);263 expectCallbacks([[20, 25], [25, 30]]);264 });265 it("should fulfil in the middle of the dataset", function() {266 range.goto(20120, 20130);267 expectRangeSize(20120, 20130);268 flushAllLoads();269 expectProxyPages([805, 806]);270 expectRecords(20100, 20150);271 expectEmpty(20000, 20100);272 expectEmpty(20150, 20200);273 expectCallbacks([[20120, 20125], [20125, 20130]]);274 });275 it("should fulfil at the end of the dataset", function() {276 range.goto(99960, 99980);277 expectRangeSize(99960, 99980);278 flushAllLoads();279 expectProxyPages([3999, 4000]);280 expectRecords(99950, 100000);281 expectEmpty(99900, 99950);282 expectCallbacks([[99960, 99975], [99975, 99980]]);283 });284 });285 });286 describe("range equal to one page", function() {287 describe("range falls within a single page", function() {288 it("should fulfil at the start of the dataset", function() {289 range.goto(0, 25);290 expectRangeSize(0, 25);291 flushAllLoads();292 expectProxyPages([1]);293 expectRecords(0, 25);294 expectEmpty(25, 100);295 expectCallbacks([[0, 25]]);296 });297 it("should fulfil in the middle of the dataset", function() {298 range.goto(20000, 20025);299 expectRangeSize(20000, 20025);300 flushAllLoads();301 expectProxyPages([801]);302 expectRecords(20000, 20025);303 expectEmpty(19900, 20000);304 expectEmpty(20025, 20100);305 expectCallbacks([[20000, 20025]]);306 });307 it("should fulfil at the end of the dataset", function() {308 range.goto(99975, 100000);309 expectRangeSize(99975, 100000);310 flushAllLoads();311 expectProxyPages([4000]);312 expectRecords(99975, 100000);313 expectEmpty(99900, 99975);314 expectCallbacks([[99975, 100000]]);315 });316 });317 describe("range covers multiple pages", function() {318 it("should fulfil at the start of the dataset", function() {319 range.goto(20, 45);320 expectRangeSize(20, 45);321 flushAllLoads();322 expectProxyPages([1, 2]);323 expectRecords(0, 50);324 expectEmpty(50, 100);325 expectCallbacks([[20, 25], [25, 45]]);326 });327 it("should fulfil in the middle of the dataset", function() {328 range.goto(20120, 20145);329 expectRangeSize(20120, 20145);330 flushAllLoads();331 expectProxyPages([805, 806]);332 expectRecords(20100, 20150);333 expectEmpty(20000, 20100);334 expectEmpty(20150, 20200);335 expectCallbacks([[20120, 20125], [20125, 20145]]);336 });337 it("should fulfil at the end of the dataset", function() {338 range.goto(99955, 99985);339 expectRangeSize(99955, 99985);340 flushAllLoads();341 expectProxyPages([3999, 4000]);342 expectRecords(99950, 100000);343 expectEmpty(99900, 99950);344 expectCallbacks([[99955, 99975], [99975, 99985]]);345 });346 });347 });348 describe("range greater than 1 page", function() {349 describe("range falls on page boundaries", function() {350 it("should fulfil at the start of the dataset", function() {351 range.goto(0, 50);352 expectRangeSize(0, 50);353 flushAllLoads();354 expectProxyPages([1, 2]);355 expectRecords(0, 50);356 expectEmpty(50, 100);357 expectCallbacks([[0, 25], [25, 50]]);358 });359 it("should fulfil in the middle of the dataset", function() {360 range.goto(20000, 20050);361 expectRangeSize(20000, 20050);362 flushAllLoads();363 expectProxyPages([801, 802]);364 expectRecords(20000, 20050);365 expectEmpty(19900, 20000);366 expectEmpty(20050, 20100);367 expectCallbacks([[20000, 20025], [20025, 20050]]);368 });369 it("should fulfil at the end of the dataset", function() {370 range.goto(99950, 100000);371 expectRangeSize(99950, 100000);372 flushAllLoads();373 expectProxyPages([3999, 4000]);374 expectRecords(99950, 100000);375 expectEmpty(99900, 99950);376 expectCallbacks([[99950, 99975], [99975, 100000]]);377 });378 });379 describe("range doesn't fall on page boundaries", function() {380 it("should fulfil at the start of the dataset", function() {381 range.goto(10, 115);382 expectRangeSize(10, 115);383 flushAllLoads();384 expectProxyPages([1, 2, 3, 4, 5]);385 expectRecords(0, 125);386 expectEmpty(125, 250);387 expectCallbacks([[10, 25], [25, 50], [50, 75], [75, 100], [100, 115]]);388 });389 it("should fulfil in the middle of the dataset", function() {390 range.goto(20010, 20115);391 expectRangeSize(20010, 20115);392 flushAllLoads();393 expectProxyPages([801, 802, 803, 804, 805]);394 expectRecords(20000, 20125);395 expectEmpty(19900, 20000);396 expectEmpty(20150, 20200);397 expectCallbacks([[20010, 20025], [20025, 20050], [20050, 20075], [20075, 20100], [20100, 20115]]);398 });399 it("should fulfil at the end of the dataset", function() {400 range.goto(99930, 99985);401 expectRangeSize(99930, 99985);402 flushAllLoads();403 expectProxyPages([3998, 3999, 4000]);404 expectRecords(99925, 100000);405 expectEmpty(99800, 99925);406 expectCallbacks([[99930, 99950], [99950, 99975], [99975, 99985]]);407 });408 });409 });410 });411 describe("moving the range", function() {412 describe("moving backwards without overlap", function() {413 beforeEach(function() {414 makeRange({415 begin: 510,416 end: 590417 });418 });419 describe("with no pending loads", function() {420 it("should move backwards and load the correct pages", function() {421 flushAllLoads();422 proxySpy.reset();423 callbackSpy.reset();424 range.goto(110, 180);425 expectRangeSize(110, 180);426 flushAllLoads();427 expectProxyPages([5, 6, 7, 8]);428 expectCallbacks([[110, 125], [125, 150], [150, 175], [175, 180]]);429 expectRecords(100, 200);430 expectEmpty(0, 100);431 expectEmpty(200, 600);432 });433 });434 describe("with loads in flight", function() {435 it("should not trigger unneeded pages, or callback for pages not in the range", function() {436 flushNextLoad();437 completeLatest();438 expectCallbacks([[510, 525]]);439 expectProxyPages([21, 22]);440 expectRecords(500, 525);441 expectEmpty(525, 600);442 callbackSpy.reset();443 range.goto(110, 180);444 expectRangeSize(110, 180);445 flushAllLoads();446 expectProxyPages([21, 22, 5, 6, 7, 8]);447 expectCallbacks([[110, 125], [125, 150], [150, 175], [175, 180]]);448 expectRecords(100, 200);449 expectEmpty(0, 100);450 expectEmpty(200, 600);451 });452 });453 });454 describe("moving backwards with overlap", function() {455 beforeEach(function() {456 makeRange({457 begin: 505,458 end: 595459 });460 });461 describe("with no pending loads", function() {462 it("should move backwards and only load required pages", function() {463 flushAllLoads();464 proxySpy.reset();465 callbackSpy.reset();466 range.goto(460, 560);467 expectRangeSize(460, 560);468 flushAllLoads();469 expectProxyPages([19, 20]);470 expectCallbacks([[460, 475], [475, 500]]);471 expectRecords(450, 575);472 expectEmpty(400, 450);473 expectEmpty(575, 600);474 });475 });476 describe("with loads in flight", function() {477 describe("no loads outside range", function() {478 it("should not trigger unneeded pages, or callback for pages not in the range", function() {479 flushNextLoad();480 completeLatest();481 expectCallbacks([[505, 525]]);482 expectProxyPages([21, 22]);483 expectRecords(500, 525);484 expectEmpty(525, 600);485 callbackSpy.reset();486 range.goto(460, 560);487 expectRangeSize(460, 560);488 flushAllLoads();489 expectProxyPages([21, 22, 23, 19, 20]);490 expectCallbacks([[525, 550], [550, 560], [460, 475], [475, 500]]);491 expectRecords(450, 575);492 expectEmpty(400, 450);493 expectEmpty(575, 650);494 });495 });496 describe("loads outside range", function() {497 it("should not trigger unneeded pages, or callback for pages not in the range", function() {498 flushNextLoad();499 completeLatest();500 completeLatest();501 completeLatest();502 expectCallbacks([[505, 525], [525, 550], [550, 575]]);503 expectProxyPages([21, 22, 23, 24]);504 expectRecords(500, 575);505 expectEmpty(575, 600);506 callbackSpy.reset();507 range.goto(460, 560);508 expectRangeSize(460, 560);509 flushAllLoads();510 expectProxyPages([21, 22, 23, 24, 19, 20]);511 expectCallbacks([[460, 475], [475, 500]]);512 expectRecords(450, 575);513 expectEmpty(400, 450);514 expectEmpty(575, 650);515 });516 });517 });518 });519 describe("narrowing a range", function() {520 beforeEach(function() {521 makeRange({522 begin: 630,523 end: 720524 });525 });526 describe("with no pending loads", function() {527 it("should not trigger any loads", function() {528 flushAllLoads();529 proxySpy.reset();530 callbackSpy.reset();531 range.goto(660, 710);532 expectRangeSize(660, 710);533 expect(proxySpy).not.toHaveBeenCalled();534 expect(callbackSpy).not.toHaveBeenCalled();535 });536 });537 describe("with loads in flight", function() {538 it("should not trigger unneeded pages, or callback for pages not in the range", function() {539 flushNextLoad();540 completeLatest();541 expectCallbacks([[630, 650]]);542 expectProxyPages([26, 27]);543 expectRecords(626, 650);544 expectEmpty(650, 750);545 callbackSpy.reset();546 range.goto(710, 720);547 expectRangeSize(710, 720);548 flushAllLoads();549 expectProxyPages([26, 27, 29]);550 expectCallbacks([[710, 720]]);551 expectRecords(700, 725);552 expectEmpty(600, 700);553 expectEmpty(725, 750);554 });555 });556 });557 describe("widening a range", function() {558 beforeEach(function() {559 makeRange({560 begin: 450,561 end: 550562 });563 });564 describe("with no pending loads", function() {565 it("should only load the required pages", function() {566 flushAllLoads();567 proxySpy.reset();568 callbackSpy.reset();569 range.goto(400, 600);570 expectRangeSize(400, 600);571 flushAllLoads();572 expectProxyPages([17, 18, 23, 24]);573 expectCallbacks([[400, 425], [425, 450], [550, 575], [575, 600]]);574 expectRecords(400, 600);575 });576 });577 describe("with loads in flight", function() {578 it("should append any newly required loads", function() {579 flushNextLoad();580 completeLatest();581 expectCallbacks([[450, 475]]);582 expectProxyPages([19, 20]);583 expectRecords(450, 475);584 expectEmpty(400, 450);585 expectEmpty(475, 600);586 callbackSpy.reset();587 range.goto(400, 600);588 expectRangeSize(400, 600);589 flushAllLoads();590 expectProxyPages([19, 20, 21, 22, 17, 18, 23, 24]);591 expectCallbacks([[475, 500], [500, 525], [525, 550], [400, 425], [425, 450], [550, 575], [575, 600]]);592 expectRecords(400, 600);593 });594 });595 });596 describe("moving forwards with overlap", function() {597 beforeEach(function() {598 makeRange({599 begin: 505,600 end: 595601 });602 });603 describe("with no pending loads", function() {604 it("should move forwards and only load required pages", function() {605 flushAllLoads();606 proxySpy.reset();607 callbackSpy.reset();608 range.goto(550, 640);609 expectRangeSize(550, 640);610 flushAllLoads();611 expectProxyPages([25, 26]);612 expectCallbacks([[600, 625], [625, 640]]);613 expectRecords(550, 650);614 expectEmpty(500, 550);615 expectEmpty(650, 700);616 });617 });618 describe("with loads in flight", function() {619 describe("no loads outside range", function() {620 it("should not trigger unneeded pages, or callback for pages not in the range", function() {621 flushNextLoad();622 completeLatest();623 completeLatest();624 expectCallbacks([[505, 525], [525, 550]]);625 expectProxyPages([21, 22, 23]);626 expectRecords(500, 550);627 expectEmpty(550, 600);628 callbackSpy.reset();629 range.goto(550, 640);630 expectRangeSize(550, 640);631 flushAllLoads();632 expectProxyPages([21, 22, 23, 24, 25, 26]);633 expectCallbacks([[550, 575], [575, 600], [600, 625], [625, 640]]);634 expectRecords(550, 650);635 expectEmpty(500, 550);636 expectEmpty(650, 700);637 });638 });639 describe("loads outside range", function() {640 it("should not trigger unneeded pages, or callback for pages not in the range", function() {641 flushNextLoad();642 completeLatest();643 expectCallbacks([[505, 525]]);644 expectProxyPages([21, 22]);645 expectRecords(500, 525);646 expectEmpty(525, 600);647 callbackSpy.reset();648 range.goto(550, 640);649 expectRangeSize(550, 640);650 flushAllLoads();651 expectProxyPages([21, 22, 23, 24, 25, 26]);652 expectCallbacks([[550, 575], [575, 600], [600, 625], [625, 640]]);653 expectRecords(550, 650);654 expectEmpty(500, 550);655 expectEmpty(650, 700);656 });657 });658 });659 });660 describe("moving forwards without overlap", function() {661 beforeEach(function() {662 makeRange({663 begin: 110,664 end: 180665 });666 });667 describe("with no pending loads", function() {668 it("should move backwards and load the correct pages", function() {669 flushAllLoads();670 proxySpy.reset();671 callbackSpy.reset();672 range.goto(510, 590);673 expectRangeSize(510, 590);674 flushAllLoads();675 expectProxyPages([21, 22, 23, 24]);676 expectCallbacks([[510, 525], [525, 550], [550, 575], [575, 590]]);677 expectRecords(500, 600);678 expectEmpty(100, 500);679 expectEmpty(600, 650);680 });681 });682 describe("with loads in flight", function() {683 it("should not trigger unneeded pages, or callback for pages not in the range", function() {684 flushNextLoad();685 completeLatest();686 expectCallbacks([[110, 125]]);687 expectProxyPages([5, 6]);688 expectRecords(100, 125);689 expectEmpty(125, 600);690 callbackSpy.reset();691 range.goto(510, 590);692 expectRangeSize(510, 590);693 flushAllLoads();694 expectProxyPages([5, 6, 21, 22, 23, 24]);695 expectCallbacks([[510, 525], [525, 550], [550, 575], [575, 590]]);696 expectRecords(500, 600);697 expectEmpty(100, 500);698 expectEmpty(600, 650);699 });700 });701 });702 describe("rapid movement", function() {703 it("should not trigger any loads straight away", function() {704 makeRange({705 begin: 0,706 end: 100707 });708 flushAllLoads();709 proxySpy.reset();710 range.goto(50, 150);711 expect(proxySpy).not.toHaveBeenCalled();712 range.goto(100, 200);713 expect(proxySpy).not.toHaveBeenCalled();714 range.goto(150, 250);715 expect(proxySpy).not.toHaveBeenCalled();716 range.goto(200, 300);717 expect(proxySpy).not.toHaveBeenCalled();718 range.goto(2000, 2200);719 expect(proxySpy).not.toHaveBeenCalled();720 flushAllLoads();721 });722 });723 });724 describe("callback", function() {725 // Callback behaviour will be tested in other loading tests726 describe("types", function() {727 describe("as function", function() {728 it("should default to global scope", function() {729 makeRange();730 range.goto(0, 25);731 flushAllLoads();732 expect(callbackSpy.mostRecentCall.object).toBe(Ext.global);733 });734 it("should use a passed scope", function() {735 var scope = {};736 makeRange({737 scope: scope738 });739 range.goto(0, 25);740 flushAllLoads();741 expect(callbackSpy.mostRecentCall.object).toBe(scope);742 });743 });744 describe("as string", function() {745 it("should call the function", function() {746 var scope = {747 theCallback: callbackSpy748 };749 makeRange({750 callback: 'theCallback',751 scope: scope752 });753 range.goto(0, 25);754 flushAllLoads();755 expect(callbackSpy.mostRecentCall.object).toBe(scope);756 });757 });758 });759 });760 describe("concurrent loading", function() {761 it("should only load the max concurrent pages", function() {762 pageMap.setConcurrentLoading(1);763 makeRange();764 range.goto(0, 100);765 flushNextLoad();766 expectProxyPages([1]);767 expect(Ext.Ajax.mockGetAllRequests().length).toBe(1);768 completeLatest();769 expectProxyPages([1, 2]);770 expect(Ext.Ajax.mockGetAllRequests().length).toBe(1);771 completeLatest();772 expectProxyPages([1, 2, 3]);773 expect(Ext.Ajax.mockGetAllRequests().length).toBe(1);774 completeLatest();775 expectProxyPages([1, 2, 3, 4]);776 expect(Ext.Ajax.mockGetAllRequests().length).toBe(1);777 completeLatest();778 expect(Ext.Ajax.mockGetAllRequests().length).toBe(0);779 });780 it("should be able to load multiple pages concurrently", function() {781 pageMap.setConcurrentLoading(2);782 makeRange();783 range.goto(0, 225);784 flushNextLoad();785 for (var i = 0; i < 8; ++i) {786 expect(Ext.Ajax.mockGetAllRequests().length).toBe(2);787 completeCall(i);788 }789 // Final request790 expect(Ext.Ajax.mockGetAllRequests().length).toBe(1);791 completeLatest();792 });793 });794 describe("caching", function() {795 var size;796 beforeEach(function() {797 size = pageMap.getCacheSize();798 });799 afterEach(function() {800 size = null;801 });802 it("should be able to hold the whole range, regardless of cache size", function() {803 makeRange();804 range.goto(0, total);805 flushAllLoads();806 expectRecords(0, total);807 });808 it("should not discard cached pages immediately", function() {809 makeRange();810 range.goto(0, 100);811 flushAllLoads();812 range.goto(100, 200);813 flushAllLoads();814 proxySpy.reset();815 callbackSpy.reset();816 range.goto(0, 100);817 expect(proxySpy).not.toHaveBeenCalled();818 expect(callbackSpy).not.toHaveBeenCalled();819 });820 it("should discard pages once they fall out of the cache", function() {821 makeRange();822 range.goto(0, 25);823 flushAllLoads();824 for (var i = 1; i <= size + 1; ++i) {825 range.goto(i * pageSize, i * pageSize + pageSize);826 flushAllLoads();827 }828 proxySpy.reset();829 // Page 0 should not exist in the cache830 range.goto(0, 25);831 flushAllLoads();832 expectProxyPages([1]);833 });834 it("should be able to recycle pages", function() {835 makeRange();836 range.goto(0, 25);837 flushAllLoads();838 for (var i = 1; i < size + 1; ++i) {839 range.goto(i * pageSize, i * pageSize + pageSize);840 flushAllLoads();841 }842 proxySpy.reset();843 callbackSpy.reset();844 // Cache is exactly full now845 range.goto(0, 25);846 flushAllLoads();847 for (i = 1; i < size + 1; ++i) {848 range.goto(i * pageSize, i * pageSize + pageSize);849 flushAllLoads();850 }851 expect(proxySpy).not.toHaveBeenCalled();852 expect(callbackSpy).not.toHaveBeenCalled();853 });854 it("should only remove the least recently used pages", function() {855 makeRange();856 range.goto(0, 25);857 flushAllLoads();858 for (var i = 1; i < size + 1; ++i) {859 range.goto(i * pageSize, i * pageSize + pageSize);860 flushAllLoads();861 }862 range.goto(0, 25);863 flushAllLoads();864 range.goto(1000, 1025);865 flushAllLoads();866 range.goto(0, 25);867 flushAllLoads();868 proxySpy.reset();869 range.goto(25, 50);870 flushAllLoads();871 expectProxyPages([2]);872 });873 });874 describe("changing range size", function() {875 it("should correct the range size when the initial size is smaller than the preflight", function() {876 makeRange();877 range.goto(0, 100);878 flushNextLoad();879 completeWithData(makeData(9), 9);880 expect(Ext.Ajax.mockGetAllRequests().length).toBe(0);881 expect(function() {882 range.goto(0, 9);883 }).not.toThrow();884 });885 });886 });887 describe("with prefetching", function() {888 function makeRange(cfg) {889 range = store.createActiveRange(Ext.apply({890 delay: 0,891 prefetch: true,892 callback: callbackSpy893 }, cfg));894 }895 describe("construction", function() {896 it("should not alter the range, or make any requests", function() {897 makeRange();898 expectRangeSize(0, 0);899 flushNextLoad();900 expect(proxySpy).not.toHaveBeenCalled();901 });902 it("should make data requests if begin was specified", function() {903 makeRange({904 begin: 0,905 end: 100906 });907 expectRangeSize(0, 100);908 flushAllLoads();909 expect(proxySpy.callCount).toBe(12);910 });911 });912 describe("basic loading functionality", function() {913 beforeEach(function() {914 makeRange();915 });916 describe("pageSize", function() {917 it("should use the store page size", function() {918 store.setPageSize(50);919 range.goto(0, 100);920 flushAllLoads();921 expectProxyPages(makePageRange(1, 6));922 expectCallbacks([[0, 50], [50, 100]]);923 expectRecords(0, 100);924 });925 });926 describe("buffer sizes", function() {927 it("should use custom leading/trailing buffers", function() {928 range.destroy();929 makeRange({930 leadingBufferZone: 100,931 trailingBufferZone: 350932 });933 range.goto(500, 600);934 flushAllLoads();935 expectProxyPages([21, 22, 23, 24, 25, 20, 26, 19, 27, 18, 28].concat(makePageRange(17, 7)));936 expectCallbacks([[500, 525], [525, 550], [550, 575], [575, 600]]);937 expectRecords(500, 600);938 });939 });940 describe("range constraints", function() {941 describe("total not known", function() {942 it("should constrain the leading buffer to 0", function() {943 range.goto(0, 100);944 expectRangeSize(0, 100);945 flushAllLoads();946 expectProxyPages(makePageRange(1, 12));947 });948 it("should allow for any size load", function() {949 range.goto(total * 2, total * 2 + pageSize * 4);950 expectRangeSize(total * 2, total * 2 + pageSize * 4);951 flushAllLoads();952 expectProxyPages([8001]);953 expect(callbackSpy).not.toHaveBeenCalled();954 });955 });956 describe("total known", function() {957 it("should raise an exception if passing a known count", function() {958 range.goto(0, 100);959 flushAllLoads();960 proxySpy.reset();961 callbackSpy.reset();962 expect(function() {963 range.goto(total * 2, total * 2 + pageSize);964 }).toThrow();965 flushAllLoads();966 expect(proxySpy).not.toHaveBeenCalled();967 expect(callbackSpy).not.toHaveBeenCalled();968 });969 it("should limit prefetching to the upper bound", function() {970 range.goto(0, 100);971 expectRangeSize(0, 100);972 flushAllLoads();973 proxySpy.reset();974 callbackSpy.reset();975 range.goto(99975, 100000);976 flushAllLoads();977 expectProxyPages([4000, 3999, 3998]);978 });979 });980 });981 describe("range smaller than the page size", function() {982 describe("range falls within a single page", function() {983 it("should fulfil at the start of the dataset", function() {984 range.goto(10, 20);985 expectRangeSize(10, 20);986 flushAllLoads();987 expectProxyPages(makePageRange(1, 9));988 expectRecords(0, 25);989 expectEmpty(25, 100);990 expectCallbacks([[10, 20]]);991 });992 it("should fulfil in the middle of the dataset", function() {993 range.goto(20005, 20015);994 expectRangeSize(20005, 20015);995 flushAllLoads();996 expectProxyPages([801, 802, 800, 803, 799, 804, 805, 806, 807, 808, 809]);997 expectRecords(20000, 20025);998 expectEmpty(19900, 20000);999 expectEmpty(20025, 20100);1000 expectCallbacks([[20005, 20015]]);1001 });1002 it("should fulfil at the end of the dataset", function() {1003 range.goto(99980, 99990);1004 expectRangeSize(99980, 99990);1005 flushAllLoads();1006 expectProxyPages([4000, 3999, 3998]);1007 expectRecords(99975, 100000);1008 expectEmpty(99900, 99975);1009 expectCallbacks([[99980, 99990]]);1010 });1011 });1012 describe("range covers multiple pages", function() {1013 it("should fulfil at the start of the dataset", function() {1014 range.goto(20, 30);1015 expectRangeSize(20, 30);1016 flushAllLoads();1017 expectProxyPages(makePageRange(1, 10));1018 expectRecords(0, 50);1019 expectEmpty(50, 100);1020 expectCallbacks([[20, 25], [25, 30]]);1021 });1022 it("should fulfil in the middle of the dataset", function() {1023 range.goto(20120, 20130);1024 expectRangeSize(20120, 20130);1025 flushAllLoads();1026 expectProxyPages([805, 806, 807, 804, 808, 803, 809, 810, 811, 812, 813, 814]);1027 expectRecords(20100, 20150);1028 expectEmpty(20000, 20100);1029 expectEmpty(20150, 20200);1030 expectCallbacks([[20120, 20125], [20125, 20130]]);1031 });1032 it("should fulfil at the end of the dataset", function() {1033 range.goto(99960, 99980);1034 expectRangeSize(99960, 99980);1035 flushAllLoads();1036 expectProxyPages([3999, 4000, 3998, 3997]);1037 expectRecords(99950, 100000);1038 expectEmpty(99900, 99950);1039 expectCallbacks([[99960, 99975], [99975, 99980]]);1040 });1041 });1042 });1043 describe("range equal to one page", function() {1044 describe("range falls within a single page", function() {1045 it("should fulfil at the start of the dataset", function() {1046 range.goto(0, 25);1047 expectRangeSize(0, 25);1048 flushAllLoads();1049 expectProxyPages(makePageRange(1, 9));1050 expectRecords(0, 25);1051 expectEmpty(25, 100);1052 expectCallbacks([[0, 25]]);1053 });1054 it("should fulfil in the middle of the dataset", function() {1055 range.goto(20000, 20025);1056 expectRangeSize(20000, 20025);1057 flushAllLoads();1058 expectProxyPages([801, 802, 800, 803, 799, 804, 805, 806, 807, 808, 809]);1059 expectRecords(20000, 20025);1060 expectEmpty(19900, 20000);1061 expectEmpty(20025, 20100);1062 expectCallbacks([[20000, 20025]]);1063 });1064 it("should fulfil at the end of the dataset", function() {1065 range.goto(99975, 100000);1066 expectRangeSize(99975, 100000);1067 flushAllLoads();1068 expectProxyPages([4000, 3999, 3998]);1069 expectRecords(99975, 100000);1070 expectEmpty(99900, 99975);1071 expectCallbacks([[99975, 100000]]);1072 });1073 });1074 describe("range covers multiple pages", function() {1075 it("should fulfil at the start of the dataset", function() {1076 range.goto(20, 45);1077 expectRangeSize(20, 45);1078 flushAllLoads();1079 expectProxyPages(makePageRange(1, 10));1080 expectRecords(0, 50);1081 expectEmpty(50, 100);1082 expectCallbacks([[20, 25], [25, 45]]);1083 });1084 it("should fulfil in the middle of the dataset", function() {1085 range.goto(20120, 20145);1086 expectRangeSize(20120, 20145);1087 flushAllLoads();1088 expectProxyPages([805, 806, 807, 804, 808, 803, 809, 810, 811, 812, 813, 814]);1089 expectRecords(20100, 20150);1090 expectEmpty(20000, 20100);1091 expectEmpty(20150, 20200);1092 expectCallbacks([[20120, 20125], [20125, 20145]]);1093 });1094 it("should fulfil at the end of the dataset", function() {1095 range.goto(99955, 99985);1096 expectRangeSize(99955, 99985);1097 flushAllLoads();1098 expectProxyPages([3999, 4000, 3998, 3997]);1099 expectRecords(99950, 100000);1100 expectEmpty(99900, 99950);1101 expectCallbacks([[99955, 99975], [99975, 99985]]);1102 });1103 });1104 });1105 describe("range greater than 1 page", function() {1106 describe("range falls on page boundaries", function() {1107 it("should fulfil at the start of the dataset", function() {1108 range.goto(0, 50);1109 expectRangeSize(0, 50);1110 flushAllLoads();1111 expectProxyPages(makePageRange(1, 10));1112 expectRecords(0, 50);1113 expectEmpty(50, 100);1114 expectCallbacks([[0, 25], [25, 50]]);1115 });1116 it("should fulfil in the middle of the dataset", function() {1117 range.goto(20000, 20050);1118 expectRangeSize(20000, 20050);1119 flushAllLoads();1120 expectProxyPages([801, 802, 803, 800, 804, 799, 805, 806, 807, 808, 809, 810]);1121 expectRecords(20000, 20050);1122 expectEmpty(19900, 20000);1123 expectEmpty(20050, 20100);1124 expectCallbacks([[20000, 20025], [20025, 20050]]);1125 });1126 it("should fulfil at the end of the dataset", function() {1127 range.goto(99950, 100000);1128 expectRangeSize(99950, 100000);1129 flushAllLoads();1130 expectProxyPages([3999, 4000, 3998, 3997]);1131 expectRecords(99950, 100000);1132 expectEmpty(99900, 99950);1133 expectCallbacks([[99950, 99975], [99975, 100000]]);1134 });1135 });1136 describe("range doesn't fall on page boundaries", function() {1137 it("should fulfil at the start of the dataset", function() {1138 range.goto(10, 115);1139 expectRangeSize(10, 115);1140 flushAllLoads();1141 expectProxyPages(makePageRange(1, 13));1142 expectRecords(0, 125);1143 expectEmpty(125, 250);1144 expectCallbacks([[10, 25], [25, 50], [50, 75], [75, 100], [100, 115]]);1145 });1146 it("should fulfil in the middle of the dataset", function() {1147 range.goto(20010, 20115);1148 expectRangeSize(20010, 20115);1149 flushAllLoads();1150 expectProxyPages([801, 802, 803, 804, 805, 806, 800, 807, 799, 808, 809, 810, 811, 812, 813]);1151 expectRecords(20000, 20125);1152 expectEmpty(19900, 20000);1153 expectEmpty(20150, 20200);1154 expectCallbacks([[20010, 20025], [20025, 20050], [20050, 20075], [20075, 20100], [20100, 20115]]);1155 });1156 it("should fulfil at the end of the dataset", function() {1157 range.goto(99930, 99985);1158 expectRangeSize(99930, 99985);1159 flushAllLoads();1160 expectProxyPages([3998, 3999, 4000, 3997, 3996]);1161 expectRecords(99925, 100000);1162 expectEmpty(99800, 99925);1163 expectCallbacks([[99930, 99950], [99950, 99975], [99975, 99985]]);1164 });1165 });1166 });1167 });1168 describe("moving the range", function() {1169 describe("moving backwards without overlap", function() {1170 beforeEach(function() {1171 makeRange({1172 begin: 510,1173 end: 5901174 });1175 });1176 describe("with no pending loads", function() {1177 it("should move backwards and load the correct pages", function() {1178 flushAllLoads();1179 proxySpy.reset();1180 callbackSpy.reset();1181 range.goto(110, 180);1182 expectRangeSize(110, 180);1183 flushAllLoads();1184 expectProxyPages([5, 6, 7, 8, 4, 9, 3, 10, 2, 1]);1185 expectCallbacks([[110, 125], [125, 150], [150, 175], [175, 180]]);1186 expectRecords(100, 200);1187 expectEmpty(0, 100);1188 expectEmpty(200, 600);1189 });1190 });1191 describe("with loads in flight", function() {1192 describe("active pages in flight", function() {1193 it("should not trigger unneeded pages, or callback for pages not in the range", function() {1194 flushNextLoad();1195 completeLatest();1196 expectCallbacks([[510, 525]]);1197 expectProxyPages([21, 22]);1198 expectRecords(500, 525);1199 expectEmpty(525, 600);1200 callbackSpy.reset();1201 range.goto(110, 180);1202 expectRangeSize(110, 180);1203 flushAllLoads();1204 expectProxyPages([21, 22, 5, 6, 7, 8, 4, 9, 3, 10, 2, 1]);1205 expectCallbacks([[110, 125], [125, 150], [150, 175], [175, 180]]);1206 expectRecords(100, 200);1207 expectEmpty(0, 100);1208 expectEmpty(200, 600);1209 });1210 });1211 describe("prefetch pages in flight", function() {1212 it("should not trigger unneeded pages, or callback for pages not in the range", function() {1213 flushNextLoad();1214 completeLatest(5);1215 expectCallbacks([[510, 525], [525, 550], [550, 575], [575, 590]]);1216 expectProxyPages([21, 22, 23, 24, 25, 20]);1217 expectRecords(500, 600);1218 expectEmpty(450, 500);1219 expectEmpty(600, 650);1220 callbackSpy.reset();1221 range.goto(110, 180);1222 expectRangeSize(110, 180);1223 flushAllLoads();1224 expectProxyPages([21, 22, 23, 24, 25, 20, 5, 6, 7, 8, 4, 9, 3, 10, 2, 1]);1225 expectCallbacks([[110, 125], [125, 150], [150, 175], [175, 180]]);1226 expectRecords(100, 200);1227 expectEmpty(0, 100);1228 expectEmpty(200, 600);1229 });1230 });1231 });1232 });1233 describe("moving backwards with overlap", function() {1234 describe("previous move backwards", function() {1235 beforeEach(function() {1236 makeRange({1237 begin: 2000,1238 end: 21001239 });1240 flushAllLoads();1241 proxySpy.reset();1242 callbackSpy.reset();1243 });1244 describe("with no pending loads", function() {1245 beforeEach(function() {1246 range.goto(705, 795);1247 flushAllLoads();1248 proxySpy.reset();1249 callbackSpy.reset();1250 });1251 describe("overlap with only the active range", function() {1252 it("should move backwards and not load any pages", function() {1253 range.goto(701, 745);1254 expectRangeSize(701, 745);1255 flushAllLoads();1256 expect(proxySpy).not.toHaveBeenCalled();1257 expect(callbackSpy).not.toHaveBeenCalled();1258 expectRecords(700, 750);1259 expectEmpty(650, 700);1260 expectEmpty(750, 800);1261 });1262 });1263 describe("overlap with the active and prefetch range", function() {1264 it("should move backwards and load the prefetch pages", function() {1265 range.goto(660, 760);1266 expectRangeSize(660, 760);1267 flushAllLoads();1268 expectProxyPages([20, 19]);1269 expect(callbackSpy).not.toHaveBeenCalled();1270 expectRecords(650, 775);1271 expectEmpty(600, 650);1272 expectEmpty(775, 800);1273 });1274 });1275 describe("overlap with only the prefetch range", function() {1276 it("should move backwards and load the prefetch pages", function() {1277 range.goto(455, 545);1278 expectRangeSize(455, 545);1279 flushAllLoads();1280 expectProxyPages([19, 20, 18, 17, 16, 15, 14, 13, 12, 11]);1281 expectCallbacks([[455, 475], [475, 500]]);1282 expectRecords(450, 550);1283 expectEmpty(400, 450);1284 expectEmpty(550, 600);1285 expectEmpty(700, 800);1286 });1287 });1288 });1289 describe("with loads in flight", function() {1290 beforeEach(function() {1291 range.goto(505, 595);1292 });1293 describe("overlap with only the active range", function() {1294 describe("with active loads in flight", function() {1295 it("should complete the appropriate loads", function() {1296 flushNextLoad();1297 completeLatest();1298 expectProxyPages([21, 22]);1299 expectCallbacks([[505, 525]]);1300 expectRecords(500, 525);1301 expectEmpty(450, 500);1302 expectEmpty(525, 600);1303 callbackSpy.reset();1304 range.goto(501, 545);1305 expectRangeSize(501, 545);1306 flushAllLoads();1307 expectProxyPages([21, 22, 20, 23, 19, 24, 18, 17, 16, 15, 14, 13]);1308 expectCallbacks([[525, 545]]);1309 expectRecords(500, 550);1310 expectEmpty(450, 500);1311 expectEmpty(550, 600);1312 });1313 });1314 describe("with prefetch loads in flight", function() {1315 it("should complete the appropriate loads", function() {1316 flushNextLoad();1317 completeLatest(7);1318 expectProxyPages([21, 22, 23, 24, 20, 25, 19, 26]);1319 expectCallbacks([[505, 525], [525, 550], [550, 575], [575, 595]]);1320 expectRecords(500, 600);1321 expectEmpty(450, 500);1322 expectEmpty(600, 700);1323 callbackSpy.reset();1324 range.goto(501, 545);1325 expectRangeSize(501, 545);1326 flushAllLoads();1327 expectProxyPages([21, 22, 23, 24, 20, 25, 19, 26, 18, 17, 16, 15, 14, 13]);1328 expect(callbackSpy).not.toHaveBeenCalled();1329 expectRecords(500, 550);1330 expectEmpty(450, 500);1331 expectEmpty(550, 600);1332 });1333 });1334 });1335 describe("overlap with the active and prefetch range", function() {1336 describe("with active loads in flight", function() {1337 it("should complete the appropriate loads", function() {1338 flushNextLoad();1339 completeLatest();1340 expectProxyPages([21, 22]);1341 expectCallbacks([[505, 525]]);1342 expectRecords(500, 525);1343 expectEmpty(450, 500);1344 expectEmpty(525, 600);1345 callbackSpy.reset();1346 range.goto(460, 560);1347 expectRangeSize(460, 560);1348 flushAllLoads();1349 expectProxyPages([21, 22, 23, 19, 20, 18, 24, 17, 25, 16, 15, 14, 13, 12, 11]);1350 expectCallbacks([[525, 550], [550, 560], [460, 475], [475, 500]]);1351 expectRecords(450, 575);1352 expectEmpty(400, 450);1353 expectEmpty(575, 600);1354 });1355 });1356 describe("with prefetch loads in flight", function() {1357 it("should complete the appropriate loads", function() {1358 flushNextLoad();1359 completeLatest(5);1360 expectProxyPages([21, 22, 23, 24, 20, 25]);1361 expectCallbacks([[505, 525], [525, 550], [550, 575], [575, 595]]);1362 expectRecords(500, 600);1363 expectEmpty(450, 500);1364 expectEmpty(600, 700);1365 callbackSpy.reset();1366 range.goto(460, 560);1367 expectRangeSize(460, 560);1368 flushAllLoads();1369 expectProxyPages([21, 22, 23, 24, 20, 25, 19, 18, 17, 16, 15, 14, 13, 12, 11]);1370 expectCallbacks([[460, 475]]);1371 expectRecords(450, 575);1372 expectEmpty(400, 450);1373 expectEmpty(575, 600);1374 });1375 });1376 });1377 describe("overlap with only the prefetch range", function() {1378 describe("with active loads in flight", function() {1379 it("should complete the appropriate loads", function() {1380 flushNextLoad();1381 completeLatest();1382 expectProxyPages([21, 22]);1383 expectCallbacks([[505, 525]]);1384 expectRecords(500, 525);1385 expectEmpty(450, 500);1386 expectEmpty(525, 600);1387 callbackSpy.reset();1388 range.goto(350, 450);1389 expectRangeSize(350, 450);1390 flushAllLoads();1391 expectProxyPages([21, 22, 15, 16, 17, 18, 14, 19, 13, 20, 12, 11, 10, 9, 8, 7]);1392 expectCallbacks([[350, 375], [375, 400], [400, 425], [425, 450]]);1393 expectRecords(350, 450);1394 expectEmpty(350, 300);1395 expectEmpty(450, 600);1396 });1397 });1398 describe("with prefetch loads in flight", function() {1399 it("should complete the appropriate loads", function() {1400 flushNextLoad();1401 completeLatest(7);1402 expectProxyPages([21, 22, 23, 24, 20, 25, 19, 26]);1403 expectCallbacks([[505, 525], [525, 550], [550, 575], [575, 595]]);1404 expectRecords(500, 600);1405 expectEmpty(450, 500);1406 expectEmpty(600, 700);1407 callbackSpy.reset();1408 range.goto(350, 450);1409 expectRangeSize(350, 450);1410 flushAllLoads();1411 expectProxyPages([21, 22, 23, 24, 20, 25, 19, 26, 15, 16, 17, 18, 14, 13, 12, 11, 10, 9, 8, 7]);1412 expectCallbacks([[350, 375], [375, 400], [400, 425], [425, 450]]);1413 expectRecords(350, 450);1414 expectEmpty(350, 300);1415 expectEmpty(450, 600);1416 });1417 });1418 });1419 });1420 });1421 describe("previous move forwards", function() {1422 beforeEach(function() {1423 makeRange({1424 begin: 0,1425 end: 11426 });1427 flushAllLoads();1428 proxySpy.reset();1429 callbackSpy.reset();1430 });1431 describe("with no pending loads", function() {1432 beforeEach(function() {1433 range.goto(705, 795);1434 flushAllLoads();1435 proxySpy.reset();1436 callbackSpy.reset();1437 });1438 describe("overlap with only the active range", function() {1439 it("should move backwards and and load the prefetch pages in the other direction", function() {1440 range.goto(701, 745);1441 expectRangeSize(701, 745);1442 flushAllLoads();1443 expectProxyPages(makePageRange(26, 21));1444 expect(callbackSpy).not.toHaveBeenCalled();1445 expectRecords(700, 750);1446 expectEmpty(650, 700);1447 expectEmpty(750, 800);1448 });1449 });1450 describe("overlap with the active and prefetch range", function() {1451 it("should move backwards and load the prefetch pages", function() {1452 range.goto(660, 760);1453 expectRangeSize(660, 760);1454 flushAllLoads();1455 expectProxyPages([26, 25, 24, 23, 22, 21, 20, 19]);1456 expect(callbackSpy).not.toHaveBeenCalled();1457 expectRecords(650, 775);1458 expectEmpty(600, 650);1459 expectEmpty(775, 800);1460 });1461 });1462 describe("overlap with only the prefetch range", function() {1463 it("should move backwards and load the prefetch pages", function() {1464 range.goto(575, 675);1465 expectRangeSize(575, 675);1466 flushAllLoads();1467 expectProxyPages([24, 25, 26, 23, 22, 21, 20, 19, 18, 17, 16]);1468 expectCallbacks([[575, 600], [600, 625], [625, 650]]);1469 expectRecords(575, 675);1470 expectEmpty(500, 575);1471 expectEmpty(675, 800);1472 });1473 });1474 });1475 describe("with loads in flight", function() {1476 beforeEach(function() {1477 range.goto(505, 595);1478 });1479 describe("overlap with only the active range", function() {1480 describe("with active loads in flight", function() {1481 it("should complete the appropriate loads", function() {1482 flushNextLoad();1483 completeLatest();1484 expectProxyPages([21, 22]);1485 expectCallbacks([[505, 525]]);1486 expectRecords(500, 525);1487 expectEmpty(450, 500);1488 expectEmpty(525, 600);1489 callbackSpy.reset();1490 range.goto(501, 545);1491 expectRangeSize(501, 545);1492 flushAllLoads();1493 expectProxyPages([21, 22, 20, 23, 19, 24, 18, 17, 16, 15, 14, 13]);1494 expectCallbacks([[525, 545]]);1495 expectRecords(500, 550);1496 expectEmpty(450, 500);1497 expectEmpty(550, 600);1498 });1499 });1500 describe("with prefetch loads in flight", function() {1501 it("should complete the appropriate loads", function() {1502 flushNextLoad();1503 completeLatest(7);1504 expectProxyPages([21, 22, 23, 24, 25, 20, 26, 19]);1505 expectCallbacks([[505, 525], [525, 550], [550, 575], [575, 595]]);1506 expectRecords(500, 600);1507 expectEmpty(450, 500);1508 expectEmpty(600, 700);1509 callbackSpy.reset();1510 range.goto(501, 545);1511 expectRangeSize(501, 545);1512 flushAllLoads();1513 expectProxyPages([21, 22, 23, 24, 25, 20, 26, 19, 18, 17, 16, 15, 14, 13]);1514 expect(callbackSpy).not.toHaveBeenCalled();1515 expectRecords(500, 550);1516 expectEmpty(450, 500);1517 expectEmpty(550, 600);1518 });1519 });1520 });1521 describe("overlap with the active and prefetch range", function() {1522 describe("with active loads in flight", function() {1523 it("should complete the appropriate loads", function() {1524 flushNextLoad();1525 completeLatest();1526 expectProxyPages([21, 22]);1527 expectCallbacks([[505, 525]]);1528 expectRecords(500, 525);1529 expectEmpty(450, 500);1530 expectEmpty(525, 600);1531 callbackSpy.reset();1532 range.goto(460, 560);1533 expectRangeSize(460, 560);1534 flushAllLoads();1535 expectProxyPages([21, 22, 23, 19, 20, 18, 24, 17, 25, 16, 15, 14, 13, 12, 11]);1536 expectCallbacks([[525, 550], [550, 560], [460, 475], [475, 500]]);1537 expectRecords(450, 575);1538 expectEmpty(400, 450);1539 expectEmpty(575, 600);1540 });1541 });1542 describe("with prefetch loads in flight", function() {1543 it("should complete the appropriate loads", function() {1544 flushNextLoad();1545 completeLatest(5);1546 expectProxyPages([21, 22, 23, 24, 25, 20]);1547 expectCallbacks([[505, 525], [525, 550], [550, 575], [575, 595]]);1548 expectRecords(500, 600);1549 expectEmpty(450, 500);1550 expectEmpty(600, 700);1551 callbackSpy.reset();1552 range.goto(460, 560);1553 expectRangeSize(460, 560);1554 flushAllLoads();1555 expectProxyPages([21, 22, 23, 24, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]);1556 expectCallbacks([[475, 500], [460, 475]]);1557 expectRecords(450, 575);1558 expectEmpty(400, 450);1559 expectEmpty(575, 600);1560 });1561 });1562 });1563 describe("overlap with only the prefetch range", function() {1564 describe("with active loads in flight", function() {1565 it("should complete the appropriate loads", function() {1566 flushNextLoad();1567 completeLatest();1568 expectProxyPages([21, 22]);1569 expectCallbacks([[505, 525]]);1570 expectRecords(500, 525);1571 expectEmpty(450, 500);1572 expectEmpty(525, 600);1573 callbackSpy.reset();1574 range.goto(350, 450);1575 expectRangeSize(350, 450);1576 flushAllLoads();1577 expectProxyPages([21, 22, 15, 16, 17, 18, 14, 19, 13, 20, 12, 11, 10]);1578 expectCallbacks([[350, 375], [375, 400], [400, 425], [425, 450]]);1579 expectRecords(350, 450);1580 expectEmpty(350, 300);1581 expectEmpty(450, 600);1582 });1583 });1584 describe("with prefetch loads in flight", function() {1585 it("should complete the appropriate loads", function() {1586 flushNextLoad();1587 completeLatest(7);1588 expectProxyPages([21, 22, 23, 24, 25, 20, 26, 19]);1589 expectCallbacks([[505, 525], [525, 550], [550, 575], [575, 595]]);1590 expectRecords(500, 600);1591 expectEmpty(450, 500);1592 expectEmpty(600, 700);1593 callbackSpy.reset();1594 range.goto(350, 450);1595 expectRangeSize(350, 450);1596 flushAllLoads();1597 expectProxyPages([21, 22, 23, 24, 25, 20, 26, 19, 15, 16, 17, 18, 14, 13, 12, 11, 10]);1598 expectCallbacks([[350, 375], [375, 400], [400, 425], [425, 450]]);1599 expectRecords(350, 450);1600 expectEmpty(350, 300);1601 expectEmpty(450, 600);1602 });1603 });1604 });1605 });1606 });1607 });1608 describe("narrowing a range", function() {1609 describe("previous move backwards", function() {1610 beforeEach(function() {1611 makeRange({1612 begin: 2000,1613 end: 21001614 });1615 flushAllLoads();1616 proxySpy.reset();1617 callbackSpy.reset();1618 range.goto(630, 720);1619 });1620 describe("with no pending loads", function() {1621 it("should not trigger any loads", function() {1622 flushAllLoads();1623 proxySpy.reset();1624 callbackSpy.reset();1625 range.goto(660, 705);1626 expectRangeSize(660, 705);1627 flushAllLoads();1628 expect(proxySpy).not.toHaveBeenCalled();1629 expect(callbackSpy).not.toHaveBeenCalled();1630 expectRecords(650, 725);1631 expectEmpty(600, 650);1632 expectEmpty(725, 750);1633 });1634 });1635 describe("with loads in flight", function() {1636 it("should not trigger any extra loads", function() {1637 flushNextLoad();1638 completeLatest();1639 expectProxyPages([26, 27]);1640 expectCallbacks([[630, 650]]);1641 expectRecords(625, 650);1642 expectEmpty(600, 625);1643 expectEmpty(650, 675);1644 callbackSpy.reset();1645 range.goto(660, 705);1646 expectRangeSize(660, 705);1647 flushAllLoads();1648 expectProxyPages([26, 27, 28, 29, 30, 25, 31, 24, 23, 22, 21, 20, 19]);1649 expectCallbacks([[660, 675], [675, 700], [700, 705]]);1650 expectRecords(650, 725);1651 expectEmpty(600, 650);1652 expectEmpty(725, 750);1653 });1654 });1655 });1656 describe("previous move forwards", function() {1657 beforeEach(function() {1658 makeRange({1659 begin: 0,1660 end: 11661 });1662 flushAllLoads();1663 proxySpy.reset();1664 callbackSpy.reset();1665 range.goto(630, 720);1666 });1667 describe("with no pending loads", function() {1668 it("should not trigger any loads", function() {1669 flushAllLoads();1670 proxySpy.reset();1671 callbackSpy.reset();1672 range.goto(660, 705);1673 expectRangeSize(660, 705);1674 flushAllLoads();1675 expect(proxySpy).not.toHaveBeenCalled();1676 expect(callbackSpy).not.toHaveBeenCalled();1677 expectRecords(650, 725);1678 expectEmpty(600, 650);1679 expectEmpty(725, 750);1680 });1681 });1682 describe("with loads in flight", function() {1683 it("should not trigger any extra loads", function() {1684 flushNextLoad();1685 completeLatest();1686 expectProxyPages([26, 27]);1687 expectCallbacks([[630, 650]]);1688 expectRecords(625, 650);1689 expectEmpty(600, 625);1690 expectEmpty(650, 675);1691 callbackSpy.reset();1692 range.goto(660, 705);1693 expectRangeSize(660, 705);1694 flushAllLoads();1695 expectProxyPages([26, 27, 28, 29, 30, 31, 25, 32, 33, 34, 35, 36, 37]);1696 expectCallbacks([[660, 675], [675, 700], [700, 705]]);1697 expectRecords(650, 725);1698 expectEmpty(600, 650);1699 expectEmpty(725, 750);1700 });1701 });1702 });1703 });1704 xdescribe("widening a range", function() {1705 beforeEach(function() {1706 makeRange({1707 begin: 450,1708 end: 5501709 });1710 });1711 describe("with no pending loads", function() {1712 it("should only load the required pages", function() {1713 flushAllLoads();1714 proxySpy.reset();1715 callbackSpy.reset();1716 range.goto(400, 600);1717 expectRangeSize(400, 600);1718 flushAllLoads();1719 expectProxyPages([17, 18, 23, 24]);1720 expectCallbacks([[400, 425], [425, 450], [550, 575], [575, 600]]);1721 expectRecords(400, 600);1722 });1723 });1724 describe("with loads in flight", function() {1725 it("should append any newly required loads", function() {1726 flushNextLoad();1727 completeLatest();1728 expectCallbacks([[450, 475]]);1729 expectProxyPages([19, 20]);1730 expectRecords(450, 475);1731 expectEmpty(400, 450);1732 expectEmpty(475, 600);1733 callbackSpy.reset();1734 range.goto(400, 600);1735 expectRangeSize(400, 600);1736 flushAllLoads();1737 expectProxyPages([19, 20, 21, 22, 17, 18, 23, 24]);1738 expectCallbacks([[475, 500], [500, 525], [525, 550], [400, 425], [425, 450], [550, 575], [575, 600]]);1739 expectRecords(400, 600);1740 });1741 });1742 });1743 xdescribe("moving forwards with overlap", function() {1744 beforeEach(function() {1745 makeRange({1746 begin: 505,1747 end: 5951748 });1749 });1750 describe("with no pending loads", function() {1751 it("should move forwards and only load required pages", function() {1752 flushAllLoads();1753 proxySpy.reset();1754 callbackSpy.reset();1755 range.goto(550, 640);1756 expectRangeSize(550, 640);1757 flushAllLoads();1758 expectProxyPages([25, 26]);1759 expectCallbacks([[600, 625], [625, 640]]);1760 expectRecords(550, 650);1761 expectEmpty(500, 550);1762 expectEmpty(650, 700);1763 });1764 });1765 describe("with loads in flight", function() {1766 describe("no loads outside range", function() {1767 it("should not trigger unneeded pages, or callback for pages not in the range", function() {1768 flushNextLoad();1769 completeLatest();1770 completeLatest();1771 expectCallbacks([[505, 525], [525, 550]]);1772 expectProxyPages([21, 22, 23]);1773 expectRecords(500, 550);1774 expectEmpty(550, 600);1775 callbackSpy.reset();1776 range.goto(550, 640);1777 expectRangeSize(550, 640);1778 flushAllLoads();1779 expectProxyPages([21, 22, 23, 24, 25, 26]);1780 expectCallbacks([[550, 575], [575, 600], [600, 625], [625, 640]]);1781 expectRecords(550, 650);1782 expectEmpty(500, 550);1783 expectEmpty(650, 700);1784 });1785 });1786 describe("loads outside range", function() {1787 it("should not trigger unneeded pages, or callback for pages not in the range", function() {1788 flushNextLoad();1789 completeLatest();1790 expectCallbacks([[505, 525]]);1791 expectProxyPages([21, 22]);1792 expectRecords(500, 525);1793 expectEmpty(525, 600);1794 callbackSpy.reset();1795 range.goto(550, 640);1796 expectRangeSize(550, 640);1797 flushAllLoads();1798 expectProxyPages([21, 22, 23, 24, 25, 26]);1799 expectCallbacks([[550, 575], [575, 600], [600, 625], [625, 640]]);1800 expectRecords(550, 650);1801 expectEmpty(500, 550);1802 expectEmpty(650, 700);1803 });1804 });1805 });1806 });1807 xdescribe("moving forwards without overlap", function() {1808 beforeEach(function() {1809 makeRange({1810 begin: 110,1811 end: 1801812 });1813 });1814 describe("with no pending loads", function() {1815 it("should move backwards and load the correct pages", function() {1816 flushAllLoads();1817 proxySpy.reset();1818 callbackSpy.reset();1819 range.goto(510, 590);1820 expectRangeSize(510, 590);1821 flushAllLoads();1822 expectProxyPages([21, 22, 23, 24]);1823 expectCallbacks([[510, 525], [525, 550], [550, 575], [575, 590]]);1824 expectRecords(500, 600);1825 expectEmpty(100, 500);1826 expectEmpty(600, 650);1827 });1828 });1829 describe("with loads in flight", function() {1830 it("should not trigger unneeded pages, or callback for pages not in the range", function() {1831 flushNextLoad();1832 completeLatest();1833 expectCallbacks([[110, 125]]);1834 expectProxyPages([5, 6]);1835 expectRecords(100, 125);1836 expectEmpty(125, 600);1837 callbackSpy.reset();1838 range.goto(510, 590);1839 expectRangeSize(510, 590);1840 flushAllLoads();1841 expectProxyPages([5, 6, 21, 22, 23, 24]);1842 expectCallbacks([[510, 525], [525, 550], [550, 575], [575, 590]]);1843 expectRecords(500, 600);1844 expectEmpty(100, 500);1845 expectEmpty(600, 650);1846 });1847 });1848 });1849 xdescribe("rapid movement", function() {1850 it("should not trigger any loads straight away", function() {1851 makeRange({1852 begin: 0,1853 end: 1001854 });1855 flushAllLoads();1856 proxySpy.reset();1857 range.goto(50, 150);1858 expect(proxySpy).not.toHaveBeenCalled();1859 range.goto(100, 200);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectEmpty } from 'ng-mocks';2describe('AppComponent', () => {3 beforeEach(async(() => {4 TestBed.configureTestingModule({5 }).compileComponents();6 }));7 it('should create the app', () => {8 const fixture = TestBed.createComponent(AppComponent);9 const app = fixture.debugElement.componentInstance;10 expect(app).toBeTruthy();11 });12 it('should render title in a h1 tag', () => {13 const fixture = TestBed.createComponent(AppComponent);14 fixture.detectChanges();15 const compiled = fixture.debugElement.nativeElement;16 expect(compiled.querySelector('h1').textContent).toContain('Welcome to my-app!');17 });18 it('should not find a h2 tag', () => {19 const fixture = TestBed.createComponent(AppComponent);20 fixture.detectChanges();21 const compiled = fixture.debugElement.nativeElement;22 expectEmpty(compiled.querySelector('h2'));23 });24});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectEmpty } from 'ng-mocks';2import { TestBed } from '@angular/core/testing';3import { AppComponent } from './app.component';4import { AppModule } from './app.module';5describe('AppComponent', () => {6 beforeEach(async () => {7 await TestBed.configureTestingModule({8 imports: [AppModule],9 }).compileComponents();10 });11 it('should create the app', () => {12 const fixture = TestBed.createComponent(AppComponent);13 const app = fixture.componentInstance;14 expect(app).toBeTruthy();15 });16 it('should have no elements', () => {17 const fixture = TestBed.createComponent(AppComponent);18 expectEmpty(fixture.nativeElement);19 });20});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectEmpty } from 'ng-mocks';2import { TestBed } from '@angular/core/testing';3import { AppComponent } from './app.component';4import { AppModule } from './app.module';5describe('AppComponent', () => {6 beforeEach(async () => {7 await TestBed.configureTestingModule({8 imports: [AppModule],9 }).compileComponents();10 });11 it('should have no element', () => {12 const fixture = TestBed.createComponent(AppComponent);13 fixture.detectChanges();14 expectEmpty('app-root');15 });16});17import { Component } from '@angular/core';18@Component({19})20export class AppComponent {}21import { NgModule } from '@angular/core';22import { BrowserModule } from '@angular/platform-browser';23import { AppComponent } from './app.component';24@NgModule({25 imports: [BrowserModule],26})27export class AppModule {}28{29 "compilerOptions": {30 },31}32{33 "compilerOptions": {34 "importHelpers": true,35 }36}37{38 "scripts": {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectEmpty } from 'ng-mocks';2describe('AppComponent', () => {3 beforeEach(async(() => {4 TestBed.configureTestingModule({5 }).compileComponents();6 }));7 it('should create the app', () => {8 const fixture = TestBed.createComponent(AppComponent);9 const app = fixture.debugElement.componentInstance;10 expect(app).toBeTruthy();11 });12 it('should create the app', () => {13 const fixture = TestBed.createComponent(AppComponent);14 const app = fixture.debugElement.componentInstance;15 expectEmpty(app);16 });17});18import { expectEmpty } from 'ng-mocks';19describe('AppComponent', () => {20 beforeEach(async(() => {21 TestBed.configureTestingModule({22 }).compileComponents();23 }));24 it('should create the app', () => {25 const fixture = TestBed.createComponent(AppComponent);26 const app = fixture.debugElement.componentInstance;27 expect(app).toBeTruthy();28 });29 it('should create the app', () => {30 const fixture = TestBed.createComponent(AppComponent);31 const app = fixture.debugElement.componentInstance;32 expectEmpty(app);33 });34});35import { expectEmpty } from 'ng-mocks';36describe('AppComponent', () => {37 beforeEach(async(() => {38 TestBed.configureTestingModule({39 }).compileComponents();40 }));41 it('should create the app', () => {42 const fixture = TestBed.createComponent(AppComponent);43 const app = fixture.debugElement.componentInstance;44 expect(app).toBeTruthy();45 });46 it('should create the app', () => {47 const fixture = TestBed.createComponent(AppComponent);48 const app = fixture.debugElement.componentInstance;49 expectEmpty(app);50 });51});52import { expectEmpty } from 'ng-mocks';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectEmpty } from 'ng-mocks';2import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';3import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';4import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';5import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';6import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';7import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';8import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';9import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';10import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';11import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';12import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';13import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';14import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';15import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';16import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';17import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';18import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';19import { expectEmpty } from 'ng-mocks/dist/lib/mock-helper';20import

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectEmpty } from 'ng-mocks';2describe('test', () => {3 it('should expect empty', () => {4 expectEmpty();5 });6});7import { expectEmpty } from 'ng-mocks';8describe('test', () => {9 it('should expect empty', () => {10 expectEmpty();11 });12});13import { expectEmpty } from 'ng-mocks';14describe('test', () => {15 it('should expect empty', () => {16 expectEmpty();17 });18});19import { expectEmpty } from 'ng-mocks';20describe('test', () => {21 it('should expect empty', () => {22 expectEmpty();23 });24});25import { expectEmpty } from 'ng-mocks';26describe('test', () => {27 it('should expect empty', () => {28 expectEmpty();29 });30});31import { expectEmpty } from 'ng-mocks';32describe('test', () => {33 it('should expect empty', () => {34 expectEmpty();35 });36});37import { expectEmpty } from 'ng-mocks';38describe('test', () => {39 it('should expect empty', () => {40 expectEmpty();41 });42});43import { expectEmpty } from 'ng-mocks';44describe('test', () => {45 it('should expect empty', () => {46 expectEmpty();47 });48});49import { expectEmpty } from 'ng-mocks';50describe('test', () => {51 it('should expect empty', () => {52 expectEmpty();53 });54});55import { expectEmpty } from 'ng-mocks';56describe('test', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectEmpty } from 'ng-mocks';2const fixture = TestBed.createComponent(SomeComponent);3expectEmpty(fixture.nativeElement.querySelector('div'));4import { expectEmpty } from 'ng-mocks';5const fixture = TestBed.createComponent(SomeComponent);6expectEmpty(fixture.nativeElement.querySelector('div'));7import { expectEmpty } from 'ng-mocks';8const fixture = TestBed.createComponent(SomeComponent);9expectEmpty(fixture.nativeElement.querySelector('div'));10import { expectEmpty } from 'ng-mocks';11const fixture = TestBed.createComponent(SomeComponent);12expectEmpty(fixture.nativeElement.querySelector('div'));13import { expectEmpty } from 'ng-mocks';14const fixture = TestBed.createComponent(SomeComponent);15expectEmpty(fixture.nativeElement.querySelector('div'));16import { expectEmpty } from 'ng-mocks';17const fixture = TestBed.createComponent(SomeComponent);18expectEmpty(fixture.nativeElement.querySelector('div'));19import { expectEmpty } from 'ng-mocks';20const fixture = TestBed.createComponent(SomeComponent);21expectEmpty(fixture.nativeElement.querySelector('div'));22import { expectEmpty } from 'ng-mocks';23const fixture = TestBed.createComponent(SomeComponent);24expectEmpty(fixture.nativeElement.querySelector('div'));25import { expectEmpty } from 'ng-mocks';26const fixture = TestBed.createComponent(SomeComponent);27expectEmpty(fixture.nativeElement.querySelector('div'));28import { expectEmpty } from 'ng-mocks';29const fixture = TestBed.createComponent(SomeComponent);30expectEmpty(fixture.nativeElement.querySelector('div'));31import { expectEmpty } from 'ng-mocks';32const fixture = TestBed.createComponent(SomeComponent);33expectEmpty(fixture.nativeElement.querySelector('div'));34import { expectEmpty } from 'ng-mocks

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectEmpty } from 'ng-mocks';2describe('test', () => {3 it('should be empty', () => {4 const fixture = MockRender(`5 `);6 expectEmpty(fixture.debugElement);7 });8});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful