From d75720b4a371192faaa9b30ecc68980bb327f1ed Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Thu, 22 Jun 2017 16:37:42 -0700 Subject: [PATCH] chore(test): fix menu and select for strict null check (#5316) --- src/lib/menu/menu.spec.ts | 4 +++- src/lib/select/select.spec.ts | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/menu/menu.spec.ts b/src/lib/menu/menu.spec.ts index ab4d0a66b23..d5f86b544b9 100644 --- a/src/lib/menu/menu.spec.ts +++ b/src/lib/menu/menu.spec.ts @@ -141,7 +141,9 @@ describe('MdMenu', () => { const menuPanel = overlayContainerElement.querySelector('.mat-menu-panel'); expect(menuPanel).toBeTruthy('Expected to find a menu panel.'); - expect(menuPanel.getAttribute('role')).toBe('menu', 'Expected panel to have the "menu" role.'); + + const role = menuPanel ? menuPanel.getAttribute('role') : ''; + expect(role).toBe('menu', 'Expected panel to have the "menu" role.'); }); describe('positions', () => { diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index 280edf112b7..14dc2735465 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -1461,8 +1461,9 @@ describe('MdSelect', () => { groupFixture.detectChanges(); const triggerTop = trigger.getBoundingClientRect().top; - const optionTop = overlayContainerElement.querySelector('.cdk-overlay-pane md-option') - .getBoundingClientRect().top; + + const option = overlayContainerElement.querySelector('.cdk-overlay-pane md-option'); + const optionTop = option ? option.getBoundingClientRect().top : 0; // Since the option is 18px higher than the trigger, it needs to be adjusted by 9px. expect(Math.floor(optionTop))