MCPcopy Index your code
hub / github.com/angular/components / expectOverlapping

Function expectOverlapping

src/cdk/scrolling/scrollable.spec.ts:6–20  ·  view source on GitHub ↗
(el1: ElementRef<Element>, el2: ElementRef<Element>, expected = true)

Source from the content-addressed store, hash-verified

4import {ComponentFixture, TestBed} from '@angular/core/testing';
5
6function expectOverlapping(el1: ElementRef<Element>, el2: ElementRef<Element>, expected = true) {
7 const r1 = el1.nativeElement.getBoundingClientRect();
8 const r2 = el2.nativeElement.getBoundingClientRect();
9 const actual =
10 r1.left < r2.right && r1.right > r2.left && r1.top < r2.bottom && r1.bottom > r2.top;
11 if (expected) {
12 expect(actual)
13 .withContext(`${JSON.stringify(r1)} should overlap with ${JSON.stringify(r2)}`)
14 .toBe(expected);
15 } else {
16 expect(actual)
17 .withContext(`${JSON.stringify(r1)} should not overlap with ${JSON.stringify(r2)}`)
18 .toBe(expected);
19 }
20}
21
22describe('CdkScrollable', () => {
23 let fixture: ComponentFixture<ScrollableViewport>;

Callers 1

scrollable.spec.tsFile · 0.85

Calls 1

getBoundingClientRectMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…