MCPcopy Create free account
hub / github.com/angular/components / assertPrevButtonScrolling

Function assertPrevButtonScrolling

src/material/tabs/tab-header.spec.ts:544–577  ·  view source on GitHub ↗

* Asserts that auto scrolling using the previous button works. * @param startEventName Name of the event that is supposed to start the scrolling. * @param endEventName Name of the event that is supposed to end the scrolling.

(startEventName: string, endEventName: string)

Source from the content-addressed store, hash-verified

542 * @param endEventName Name of the event that is supposed to end the scrolling.
543 */
544 async function assertPrevButtonScrolling(startEventName: string, endEventName: string) {
545 header.scrollDistance = Infinity;
546 fixture.detectChanges();
547
548 let currentScroll = header.scrollDistance;
549
550 expect(currentScroll).withContext('Expected to start off scrolled.').toBeGreaterThan(0);
551
552 dispatchFakeEvent(prevButton, startEventName);
553 fixture.detectChanges();
554 await wait(300);
555
556 expect(header.scrollDistance)
557 .withContext('Expected not to scroll after short amount of time.')
558 .toBe(currentScroll);
559
560 // Wait to exceed delay (300 + 500 = 800ms > 650ms)
561 await wait(600);
562
563 expect(header.scrollDistance)
564 .withContext('Expected to scroll after some time.')
565 .toBeLessThan(currentScroll);
566
567 currentScroll = header.scrollDistance;
568 await wait(200);
569
570 expect(header.scrollDistance)
571 .withContext('Expected to scroll again after some more time.')
572 .toBeLessThan(currentScroll);
573
574 dispatchFakeEvent(nextButton, endEventName);
575 // Wait for any cleanup or final events
576 await wait(100);
577 }
578 });
579
580 describe('disabling pagination', () => {

Callers 1

tab-header.spec.tsFile · 0.85

Calls 2

dispatchFakeEventFunction · 0.85
waitFunction · 0.70

Tested by

no test coverage detected