Skip to content

Commit

Permalink
[useScrollTrigger] Add test to fix useScrollTrigger when the page fir…
Browse files Browse the repository at this point in the history
…st load
  • Loading branch information
Marco Moretti committed Apr 21, 2020
1 parent 76f5f91 commit 026b610
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/material-ui/src/useScrollTrigger/useScrollTrigger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,16 @@ describe('useScrollTrigger', () => {
assert.strictEqual(text(), test.result, `Index: ${index} ${JSON.stringify(test)}`);
});
});

it('should correctly evaluate scroll events on page first load', () => {
[
{ offset: 101, result: 'true' },
{ offset: 100, result: 'false' },
].forEach((test, index) => {
window.pageYOffset = test.offset;
mount(<Test threshold={100} />);
assert.strictEqual(text(), test.result, `Index: ${index} ${JSON.stringify(test)}`);
});
});
});
});

0 comments on commit 026b610

Please sign in to comment.