-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor chat input context in favor of zustand store
- Loading branch information
Showing
4 changed files
with
41 additions
and
29 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
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,27 @@ | ||
import { act, renderHook } from '@testing-library/react'; | ||
import { useChatInputStore } from '../chat-input-store'; | ||
|
||
describe( 'useChatInputStore', () => { | ||
beforeEach( () => { | ||
act( () => { | ||
useChatInputStore.setState( { inputBySite: {} } ); | ||
} ); | ||
} ); | ||
|
||
it( 'saves and retrieves chat input by site', () => { | ||
const { result } = renderHook( () => useChatInputStore() ); | ||
|
||
act( () => { | ||
result.current.saveChatInput( 'test input 1', 'site-1' ); | ||
result.current.saveChatInput( 'test input 2', 'site-2' ); | ||
} ); | ||
|
||
expect( result.current.getChatInput( 'site-1' ) ).toBe( 'test input 1' ); | ||
expect( result.current.getChatInput( 'site-2' ) ).toBe( 'test input 2' ); | ||
} ); | ||
|
||
it( 'returns empty string for non-existent site input', () => { | ||
const { result } = renderHook( () => useChatInputStore() ); | ||
expect( result.current.getChatInput( 'non-existent-site' ) ).toBe( '' ); | ||
} ); | ||
} ); |