Skip to content

Commit 6ddcb68

Browse files
committed
fix tests
1 parent 82b5e85 commit 6ddcb68

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
});
@@ -234,24 +234,24 @@ describe('MdDrawer', () => {
234234
.toBe(false, 'Expected drawer not to have a native align attribute.');
235235
});
236236

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

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

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

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

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

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

371-
/** Test component that contains an MdDrawerContainer and 2 MdDrawer on the same side. */
371+
/** Test component that contains an MdDrawerContainer and 2 MdDrawer in the same position. */
372372
@Component({
373373
template: `
374374
<md-drawer-container>
375-
<md-drawer [position]="start"></md-drawer>
376-
<md-drawer [position]="end"></md-drawer>
375+
<md-drawer position="start"></md-drawer>
376+
<md-drawer position="end"></md-drawer>
377377
</md-drawer-container>`,
378378
})
379379
class DrawerContainerTwoDrawerTestApp {
@@ -384,7 +384,7 @@ class DrawerContainerTwoDrawerTestApp {
384384
@Component({
385385
template: `
386386
<md-drawer-container (backdropClick)="backdropClicked()">
387-
<md-drawer #drawer [position]="start"
387+
<md-drawer #drawer position="start"
388388
(open)="open()"
389389
(close)="close()">
390390
<button #drawerButton>Content.</button>
@@ -438,19 +438,19 @@ class DrawerSetToOpenedTrue { }
438438
@Component({
439439
template: `
440440
<md-drawer-container>
441-
<md-drawer #drawer1 [position]="drawer1Side"></md-drawer>
442-
<md-drawer #drawer2 [position]="drawer2Side"></md-drawer>
441+
<md-drawer #drawer1 [position]="drawer1Position"></md-drawer>
442+
<md-drawer #drawer2 [position]="drawer2Position"></md-drawer>
443443
</md-drawer-container>`,
444444
})
445-
class DrawerDynamicSide {
446-
drawer1Side = 'start';
447-
drawer2Side = 'end';
445+
class DrawerDynamicPosition {
446+
drawer1Position = 'start';
447+
drawer2Position = 'end';
448448
}
449449

450450
@Component({
451451
template: `
452452
<md-drawer-container>
453-
<md-drawer [position]="start" [mode]="mode">
453+
<md-drawer position="start" [mode]="mode">
454454
<a class="link1" href="#">link1</a>
455455
</md-drawer>
456456
<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

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

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

155155
/** @deprecated */
156156
@Output('align-changed') onAlignChanged = new EventEmitter<void>();
@@ -316,16 +316,16 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
316316
export class MdDrawerContainer implements AfterContentInit {
317317
@ContentChildren(MdDrawer) _drawers: QueryList<MdDrawer>;
318318

319-
/** The drawer child with the `start` side. */
319+
/** The drawer child with the `start` position. */
320320
get start() { return this._start; }
321321

322-
/** The drawer child with the `end` side. */
322+
/** The drawer child with the `end` position. */
323323
get end() { return this._end; }
324324

325325
/** Event emitted when the drawer backdrop is clicked. */
326326
@Output() backdropClick = new EventEmitter<void>();
327327

328-
/** The drawer at the start/end side, independent of direction. */
328+
/** The drawer at the start/end position, independent of direction. */
329329
private _start: MdDrawer | null;
330330
private _end: MdDrawer | null;
331331

@@ -356,7 +356,7 @@ export class MdDrawerContainer implements AfterContentInit {
356356
this._validateDrawers();
357357
this._drawers.forEach((drawer: MdDrawer) => {
358358
this._watchDrawerToggle(drawer);
359-
this._watchDrawerSide(drawer);
359+
this._watchDrawerPosition(drawer);
360360
});
361361
});
362362
}
@@ -392,14 +392,15 @@ export class MdDrawerContainer implements AfterContentInit {
392392
}
393393

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

0 commit comments

Comments
 (0)