-
Notifications
You must be signed in to change notification settings - Fork 929
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pickState): only pick relevant state (#183)
Make `toggleMenu` and friends more user-friendly by only picking out state that is relevant to downshift, allowing users to use them as event event handlers. Closes #182.
- Loading branch information
1 parent
a1490f0
commit 1cb2743
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {pickState} from '../utils' | ||
|
||
test('pickState only picks state that downshift cares about', () => { | ||
const otherStateToSet = { | ||
isOpen: true, | ||
foo: 0, | ||
} | ||
const result = pickState(otherStateToSet) | ||
const expected = {isOpen: true} | ||
const resultKeys = Object.keys(result) | ||
const expectedKeys = Object.keys(expected) | ||
resultKeys.sort() | ||
expectedKeys.sort() | ||
expect(result).toEqual(expected) | ||
expect(resultKeys).toEqual(expectedKeys) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters