Skip to content

Commit

Permalink
feat(drawer): Make list instance publicly accessible (#4516)
Browse files Browse the repository at this point in the history
  • Loading branch information
kfranqueiro authored Mar 19, 2019
1 parent 42ae5c3 commit f46941c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/mdc-drawer/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export class MDCDrawer extends MDCComponent<MDCDismissibleDrawerFoundation> {
private handleKeydown_!: SpecificEventListener<'keydown'>; // initialized in initialSyncWithDOM()
private handleTransitionEnd_!: SpecificEventListener<'transitionend'>; // initialized in initialSyncWithDOM()

get list(): MDCList | undefined {
return this.list_;
}

initialize(
focusTrapFactory: MDCDrawerFocusTrapFactory = createFocusTrap as unknown as MDCDrawerFocusTrapFactory,
listFactory: MDCListFactory = (el) => new MDCList(el),
Expand Down
7 changes: 6 additions & 1 deletion test/unit/mdc-drawer/mdc-drawer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import td from 'testdouble';

import {MDCDrawer} from '../../../packages/mdc-drawer/index';
import {strings, cssClasses} from '../../../packages/mdc-drawer/constants';
import {MDCListFoundation} from '../../../packages/mdc-list/index';
import {MDCList, MDCListFoundation} from '../../../packages/mdc-list/index';
import {MDCDismissibleDrawerFoundation} from '../../../packages/mdc-drawer/dismissible/foundation';
import {MDCModalDrawerFoundation} from '../../../packages/mdc-drawer/modal/foundation';

Expand Down Expand Up @@ -150,6 +150,11 @@ test('#set open false calls foundation.close', () => {
td.verify(mockFoundation.close(), {times: 1});
});

test('#get list returns MDCList instance when DOM includes list', () => {
const {component} = setupTest();
assert.instanceOf(component.list, MDCList);
});

test('click event calls foundation.handleScrimClick method', () => {
const {root, mockFoundation} = setupTestWithMocks({variantClass: cssClasses.MODAL});
const scrimEl = root.querySelector('.mdc-drawer-scrim');
Expand Down

0 comments on commit f46941c

Please sign in to comment.