Skip to content

Commit a495181

Browse files
committed
fix tests
1 parent 38dd659 commit a495181

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

src/lib/sidenav/drawer.spec.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('MdDrawer', () => {
1818
DrawerContainerNoDrawerTestApp,
1919
DrawerSetToOpenedFalse,
2020
DrawerSetToOpenedTrue,
21-
DrawerDynamicSide,
21+
DrawerDynamicPosition,
2222
DrawerWitFocusableElements,
2323
],
2424
});
@@ -235,24 +235,24 @@ describe('MdDrawer', () => {
235235
.toBe(false, 'Expected drawer not to have a native align attribute.');
236236
});
237237

238-
it('should throw when multiple drawers have the same side', fakeAsync(() => {
239-
const fixture = TestBed.createComponent(DrawerDynamicSide);
238+
it('should throw when multiple drawers have the same position', fakeAsync(() => {
239+
const fixture = TestBed.createComponent(DrawerDynamicPosition);
240240
fixture.detectChanges();
241241
tick();
242242

243-
const testComponent: DrawerDynamicSide = fixture.debugElement.componentInstance;
244-
testComponent.drawer1Side = 'end';
243+
const testComponent: DrawerDynamicPosition = fixture.debugElement.componentInstance;
244+
testComponent.drawer1Position = 'end';
245245

246246
expect(() => fixture.detectChanges()).toThrow();
247247
}));
248248

249-
it('should not throw when drawers swap sides', () => {
250-
const fixture = TestBed.createComponent(DrawerDynamicSide);
249+
it('should not throw when drawers swap positions', () => {
250+
const fixture = TestBed.createComponent(DrawerDynamicPosition);
251251
fixture.detectChanges();
252252

253-
const testComponent: DrawerDynamicSide = fixture.debugElement.componentInstance;
254-
testComponent.drawer1Side = 'end';
255-
testComponent.drawer2Side = 'start';
253+
const testComponent: DrawerDynamicPosition = fixture.debugElement.componentInstance;
254+
testComponent.drawer1Position = 'end';
255+
testComponent.drawer2Position = 'start';
256256

257257
expect(() => fixture.detectChanges()).not.toThrow();
258258
});
@@ -369,12 +369,12 @@ describe('MdDrawerContainer', () => {
369369
@Component({template: `<md-drawer-container></md-drawer-container>`})
370370
class DrawerContainerNoDrawerTestApp { }
371371

372-
/** Test component that contains an MdDrawerContainer and 2 MdDrawer on the same side. */
372+
/** Test component that contains an MdDrawerContainer and 2 MdDrawer in the same position. */
373373
@Component({
374374
template: `
375375
<md-drawer-container>
376-
<md-drawer [position]="start"></md-drawer>
377-
<md-drawer [position]="end"></md-drawer>
376+
<md-drawer position="start"></md-drawer>
377+
<md-drawer position="end"></md-drawer>
378378
</md-drawer-container>`,
379379
})
380380
class DrawerContainerTwoDrawerTestApp {
@@ -385,7 +385,7 @@ class DrawerContainerTwoDrawerTestApp {
385385
@Component({
386386
template: `
387387
<md-drawer-container (backdropClick)="backdropClicked()">
388-
<md-drawer #drawer [position]="start"
388+
<md-drawer #drawer position="start"
389389
(open)="open()"
390390
(close)="close()">
391391
<button #drawerButton>Content.</button>
@@ -439,19 +439,19 @@ class DrawerSetToOpenedTrue { }
439439
@Component({
440440
template: `
441441
<md-drawer-container>
442-
<md-drawer #drawer1 [position]="drawer1Side"></md-drawer>
443-
<md-drawer #drawer2 [position]="drawer2Side"></md-drawer>
442+
<md-drawer #drawer1 [position]="drawer1Position"></md-drawer>
443+
<md-drawer #drawer2 [position]="drawer2Position"></md-drawer>
444444
</md-drawer-container>`,
445445
})
446-
class DrawerDynamicSide {
447-
drawer1Side = 'start';
448-
drawer2Side = 'end';
446+
class DrawerDynamicPosition {
447+
drawer1Position = 'start';
448+
drawer2Position = 'end';
449449
}
450450

451451
@Component({
452452
template: `
453453
<md-drawer-container>
454-
<md-drawer [position]="start" [mode]="mode">
454+
<md-drawer position="start" [mode]="mode">
455455
<a class="link1" href="#">link1</a>
456456
</md-drawer>
457457
<a class="link2" href="#">link2</a>

src/lib/sidenav/drawer.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import {DOCUMENT} from '@angular/platform-browser';
3333
import {merge} from 'rxjs/observable/merge';
3434

3535

36-
/** Throws an exception when two MdDrawer are matching the same side. */
37-
export function throwMdDuplicatedDrawerError(side: string) {
38-
throw Error(`A drawer was already declared for 'side="${side}"'`);
36+
/** Throws an exception when two MdDrawer are matching the same position. */
37+
export function throwMdDuplicatedDrawerError(position: string) {
38+
throw Error(`A drawer was already declared for 'position="${position}"'`);
3939
}
4040

4141

@@ -145,8 +145,8 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
145145
/** Event emitted when the drawer is fully closed. */
146146
@Output('close') onClose = new EventEmitter<MdDrawerToggleResult | void>();
147147

148-
/** Event emitted when the drawer's side changes. */
149-
@Output('side-changed') onPositionChanged = new EventEmitter<void>();
148+
/** Event emitted when the drawer's position changes. */
149+
@Output('positionChanged') onPositionChanged = new EventEmitter<void>();
150150

151151
/** @deprecated */
152152
@Output('align-changed') onAlignChanged = new EventEmitter<void>();
@@ -311,16 +311,16 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
311311
export class MdDrawerContainer implements AfterContentInit {
312312
@ContentChildren(MdDrawer) _drawers: QueryList<MdDrawer>;
313313

314-
/** The drawer child with the `start` side. */
314+
/** The drawer child with the `start` position. */
315315
get start() { return this._start; }
316316

317-
/** The drawer child with the `end` side. */
317+
/** The drawer child with the `end` position. */
318318
get end() { return this._end; }
319319

320320
/** Event emitted when the drawer backdrop is clicked. */
321321
@Output() backdropClick = new EventEmitter<void>();
322322

323-
/** The drawer at the start/end side, independent of direction. */
323+
/** The drawer at the start/end position, independent of direction. */
324324
private _start: MdDrawer | null;
325325
private _end: MdDrawer | null;
326326

@@ -351,7 +351,7 @@ export class MdDrawerContainer implements AfterContentInit {
351351
this._validateDrawers();
352352
this._drawers.forEach((drawer: MdDrawer) => {
353353
this._watchDrawerToggle(drawer);
354-
this._watchDrawerSide(drawer);
354+
this._watchDrawerPosition(drawer);
355355
});
356356
});
357357
}
@@ -387,14 +387,15 @@ export class MdDrawerContainer implements AfterContentInit {
387387
}
388388

389389
/**
390-
* Subscribes to drawer onSideChanged event in order to re-validate drawers when the side changes.
390+
* Subscribes to drawer onPositionChanged event in order to re-validate drawers when the position
391+
* changes.
391392
*/
392-
private _watchDrawerSide(drawer: MdDrawer): void {
393+
private _watchDrawerPosition(drawer: MdDrawer): void {
393394
if (!drawer) {
394395
return;
395396
}
396397
// NOTE: We need to wait for the microtask queue to be empty before validating,
397-
// since both drawers may be swapping sides at the same time.
398+
// since both drawers may be swapping positions at the same time.
398399
takeUntil.call(drawer.onPositionChanged, this._drawers.changes).subscribe(() =>
399400
first.call(this._ngZone.onMicrotaskEmpty).subscribe(() => this._validateDrawers()));
400401
}

0 commit comments

Comments
 (0)