Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/components/sidenav/sidenav.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,45 @@ export function main() {
}).toThrow();
}));
});

describe('attributes', () => {

it('should correctly parse opened="false"', fakeAsyncAdaptor(() => {
let newBuilder = builder.overrideTemplate(BasicTestApp, `
<md-sidenav-layout>
<md-sidenav #sidenav mode="side" opened="false">
Closed Sidenav.
</md-sidenav>
</md-sidenav-layout>`);

let fixture = createFixture(BasicTestApp, newBuilder, template, style);
fixture.detectChanges();

let sidenavEl = fixture.debugElement.query(By.css('md-sidenav')).nativeElement;

expect(sidenavEl.classList).toContain('md-sidenav-closed');
expect(sidenavEl.classList).not.toContain('md-sidenav-opened');
}));

it('should correctly parse opened="true"', fakeAsyncAdaptor(() => {
let newBuilder = builder.overrideTemplate(BasicTestApp, `
<md-sidenav-layout>
<md-sidenav #sidenav mode="side" opened="true">
Closed Sidenav.
</md-sidenav>
</md-sidenav-layout>`);

let fixture = createFixture(BasicTestApp, newBuilder, template, style);
fixture.detectChanges();

let sidenavEl = fixture.debugElement.query(By.css('md-sidenav')).nativeElement;

expect(sidenavEl.classList).not.toContain('md-sidenav-closed');
expect(sidenavEl.classList).toContain('md-sidenav-opened');
}));

});

});
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/sidenav/sidenav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import {Dir} from '../../core/rtl/dir';
import {PromiseCompleter} from '../../core/async/promise-completer';
import {MdError} from '../../core/errors/error';
import { BooleanFieldValue } from '../../core/annotations/field-value';


/**
Expand Down Expand Up @@ -50,7 +51,7 @@ export class MdSidenav {
@Input() mode: 'over' | 'push' | 'side' = 'over';

/** Whether the sidenav is opened. */
@Input('opened') private _opened: boolean = false;
@Input('opened') @BooleanFieldValue() private _opened: boolean = false;

/** Event emitted when the sidenav is being opened. Use this to synchronize animations. */
@Output('open-start') onOpenStart = new EventEmitter<void>();
Expand Down