Skip to content

Commit

Permalink
Revert weird changes to dialog.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
PooSham committed Jan 9, 2022
1 parent d6deb45 commit c87c4aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 34 deletions.
3 changes: 1 addition & 2 deletions src/material-experimental/mdc-dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {By} from '@angular/platform-browser';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {numbers} from '@material/dialog';
import {Subject} from 'rxjs';

import {
MatDialog,
MatDialogModule,
Expand Down Expand Up @@ -1672,7 +1671,7 @@ describe('MDC-based MatDialog', () => {
.toBe(title.id);
}));

it('should add align-* class according to given [align] input in [mat-dialog-actions]', () => {
it('should add mat-mdc-dialog-actions-align-* class according to given [align] input in [mat-dialog-actions]', () => {
let actions = overlayContainerElement.querySelector('mat-dialog-actions')!;

expect(actions)
Expand Down
46 changes: 14 additions & 32 deletions src/material/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y';
import {Directionality} from '@angular/cdk/bidi';
import {A, ESCAPE} from '@angular/cdk/keycodes';
import {Overlay, OverlayContainer, ScrollStrategy} from '@angular/cdk/overlay';
import {ScrollDispatcher} from '@angular/cdk/scrolling';
import {
createKeyboardEvent,
dispatchEvent,
dispatchKeyboardEvent,
dispatchMouseEvent,
patchElementFocus,
} from '@angular/cdk/testing/private';
import {Location} from '@angular/common';
import {SpyLocation} from '@angular/common/testing';
ComponentFixture,
fakeAsync,
flushMicrotasks,
inject,
TestBed,
tick,
flush,
} from '@angular/core/testing';
import {
ChangeDetectionStrategy,
Component,
ComponentFactoryResolver,
Directive,
Inject,
Injector,
Expand All @@ -26,15 +21,6 @@ import {
NgZone,
ViewEncapsulation,
} from '@angular/core';
import {
ComponentFixture,
fakeAsync,
flush,
flushMicrotasks,
inject,
TestBed,
tick,
} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {Location} from '@angular/common';
Expand All @@ -54,13 +40,12 @@ import {
} from '../../cdk/testing/private';
import {
MAT_DIALOG_DATA,
MAT_DIALOG_DEFAULT_OPTIONS,
MatDialog,
MatDialogModule,
MatDialogRef,
MAT_DIALOG_DEFAULT_OPTIONS,
MatDialogState,
} from './index';

import {Subject} from 'rxjs';

describe('MatDialog', () => {
Expand Down Expand Up @@ -1396,8 +1381,7 @@ describe('MatDialog', () => {
button.focus();

// Patch the element focus after the initial and real focus, because otherwise the
// `activeElement` won't be set, and the dialog won't be able to restore focus to an
// element.
// `activeElement` won't be set, and the dialog won't be able to restore focus to an element.
patchElementFocus(button);

dialog.open(PizzaMsg, {viewContainerRef: testViewContainerRef});
Expand Down Expand Up @@ -1430,8 +1414,7 @@ describe('MatDialog', () => {
button.focus();

// Patch the element focus after the initial and real focus, because otherwise the
// `activeElement` won't be set, and the dialog won't be able to restore focus to an
// element.
// `activeElement` won't be set, and the dialog won't be able to restore focus to an element.
patchElementFocus(button);

dialog.open(PizzaMsg, {viewContainerRef: testViewContainerRef});
Expand Down Expand Up @@ -1640,10 +1623,9 @@ describe('MatDialog', () => {
'Expected the focus to change when dialog was opened.',
);

// Start the closing sequence and move focus out of dialog.
dialogRef.close();
flushMicrotasks();
viewContainerFixture.detectChanges();
tick(500);
otherButton.focus();

expect(document.activeElement!.id)
.withContext('Expected focus to be on the alternate button.')
Expand Down Expand Up @@ -1752,7 +1734,7 @@ describe('MatDialog', () => {
.toBe(title.id);
}));

it('should add align-* class according to given [align] input in [mat-dialog-actions]', () => {
it('should add mat-dialog-actions-align-* class according to given [align] input in [mat-dialog-actions]', () => {
let actions = overlayContainerElement.querySelector('mat-dialog-actions')!;

expect(actions)
Expand Down

0 comments on commit c87c4aa

Please sign in to comment.