-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* test: move some CDK tests to zoneless * test: rewrite tests that test zone.js implementation details * Revert "test: rewrite tests that test zone.js implementation details" This reverts commit de01346. * ci: fix lint * test: share drag&drop test utils
- Loading branch information
Showing
12 changed files
with
1,337 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {Platform} from '@angular/cdk/platform'; | ||
import {patchElementFocus} from '@angular/cdk/testing/private'; | ||
import {Component, NgZone, provideZoneChangeDetection} from '@angular/core'; | ||
import {ComponentFixture, TestBed, fakeAsync, inject, tick} from '@angular/core/testing'; | ||
import {A11yModule} from '../a11y-module'; | ||
import {FocusMonitor} from './focus-monitor'; | ||
|
||
describe('FocusMonitor observable stream Zone.js integration', () => { | ||
let fixture: ComponentFixture<PlainButton>; | ||
let buttonElement: HTMLElement; | ||
let focusMonitor: FocusMonitor; | ||
let fakePlatform: Platform; | ||
|
||
beforeEach(() => { | ||
fakePlatform = {isBrowser: true} as Platform; | ||
TestBed.configureTestingModule({ | ||
imports: [A11yModule, PlainButton], | ||
providers: [{provide: Platform, useValue: fakePlatform}, provideZoneChangeDetection()], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(inject([FocusMonitor], (fm: FocusMonitor) => { | ||
fixture = TestBed.createComponent(PlainButton); | ||
focusMonitor = fm; | ||
fixture.detectChanges(); | ||
buttonElement = fixture.debugElement.nativeElement.querySelector('button'); | ||
patchElementFocus(buttonElement); | ||
})); | ||
|
||
it('should emit inside the NgZone', fakeAsync(() => { | ||
const spy = jasmine.createSpy('zone spy'); | ||
focusMonitor.monitor(buttonElement).subscribe(() => spy(NgZone.isInAngularZone())); | ||
expect(spy).not.toHaveBeenCalled(); | ||
|
||
buttonElement.focus(); | ||
fixture.detectChanges(); | ||
tick(); | ||
expect(spy).toHaveBeenCalledWith(true); | ||
})); | ||
}); | ||
|
||
@Component({ | ||
template: `<div class="parent"><button>focus me!</button></div>`, | ||
standalone: true, | ||
imports: [A11yModule], | ||
}) | ||
class PlainButton {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.