-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add zustand store * move snack message to the global state * move snack message to the global state * add zustand test * add zustand test * add drawer test * add side drawer test + change testing library version * simplified storage * clean up
- Loading branch information
1 parent
ce71efc
commit 0671471
Showing
7 changed files
with
331 additions
and
224 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,12 @@ | ||
import create from 'zustand' | ||
|
||
|
||
const useStore = create((set) => ({ | ||
isDrawerOpen: false, | ||
isCommentsOn: false, | ||
snackMessage: null, | ||
setSnackMessage: (message) => set(() => ({snackMessage: message})), | ||
openDrawer: () => set(() => ({isDrawerOpen: true})), | ||
closeDrawer: () => set(() => ({isDrawerOpen: false})), | ||
})) | ||
export default useStore |
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,23 @@ | ||
import {act, renderHook} from '@testing-library/react-hooks' | ||
import useStore from './store' | ||
|
||
|
||
describe('useStore', () => { | ||
it('Set snack message', () => { | ||
const {result} = renderHook(() => useStore((state) => state)) | ||
act(() => { | ||
result.current.setSnackMessage(['loading']) | ||
}) | ||
expect(result.current.snackMessage).toEqual(['loading']) | ||
}) | ||
}) | ||
|
||
describe('useStore', () => { | ||
it('Set Drawer State', () => { | ||
const {result} = renderHook(() => useStore((state) => state)) | ||
act(() => { | ||
result.current.openDrawer() | ||
}) | ||
expect(result.current.isDrawerOpen).toEqual(true) | ||
}) | ||
}) |
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