(el1: ElementRef<Element>, el2: ElementRef<Element>, expected = true)
| 4 | import {ComponentFixture, TestBed} from '@angular/core/testing'; |
| 5 | |
| 6 | function 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 | |
| 22 | describe('CdkScrollable', () => { |
| 23 | let fixture: ComponentFixture<ScrollableViewport>; |
no test coverage detected
searching dependent graphs…