-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(top-app-bar): Move scroll target initialization; improve test #4106
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4106 +/- ##
=======================================
Coverage 98.67% 98.67%
=======================================
Files 126 126
Lines 5603 5603
Branches 747 747
=======================================
Hits 5529 5529
Misses 74 74
Continue to review full report at Codecov.
|
@@ -292,8 +291,8 @@ test('adapter#getViewportScrollY returns scroll distance', () => { | |||
|
|||
test('adapter#getViewportScrollY returns scroll distance when scrollTarget_ is not window', () => { | |||
const {component, fixture} = setupTest(); | |||
const content = fixture.querySelector('.content'); | |||
component.scrollTarget_ = content; | |||
const content = {addEventListener: () => {}, scrollTop: 20}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: mockContent*
@@ -292,8 +291,8 @@ test('adapter#getViewportScrollY returns scroll distance', () => { | |||
|
|||
test('adapter#getViewportScrollY returns scroll distance when scrollTarget_ is not window', () => { | |||
const {component, fixture} = setupTest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused variable fixture
.
All 663 screenshot tests passed for commit abe86fc vs. |
This resolves the test failure discovered in #4046.
The
getViewportScrollY
adapter unit test was coincidentally passing because the page's scroll offset and the scroll offset of the content element were typically both 0. This only ended up not being the case when I tried running our unit tests via headless Firefox on Travis.The test as written actually should never have passed, because
getDefaultFoundation
in the Top App Bar component had the side effect of resetting the scroll target, effectively undoing the test's setup.This fixes the component to initialize the scroll target in
initialize
rather thangetDefaultFoundation
, and fixes the test to use a mock object to guarantee a distinguishable expected value.