File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,35 @@ describe('useRecentSearches', () => {
3434 } ) ;
3535 expect ( result . current . searches [ 0 ] ) . toBe ( 'torvalds' ) ;
3636 } ) ;
37+ it ( 'ignores empty string input' , ( ) => {
38+ const { result } = renderHook ( ( ) => useRecentSearches ( ) ) ;
39+
40+ act ( ( ) => {
41+ result . current . addSearch ( '' ) ;
42+ } ) ;
43+
44+ expect ( result . current . searches ) . toEqual ( [ ] ) ;
45+ } ) ;
46+
47+ it ( 'ignores whitespace-only input' , ( ) => {
48+ const { result } = renderHook ( ( ) => useRecentSearches ( ) ) ;
49+
50+ act ( ( ) => {
51+ result . current . addSearch ( ' ' ) ;
52+ } ) ;
53+
54+ expect ( result . current . searches ) . toEqual ( [ ] ) ;
55+ } ) ;
56+
57+ it ( 'ignores newline-only input' , ( ) => {
58+ const { result } = renderHook ( ( ) => useRecentSearches ( ) ) ;
59+
60+ act ( ( ) => {
61+ result . current . addSearch ( '\n' ) ;
62+ } ) ;
63+
64+ expect ( result . current . searches ) . toEqual ( [ ] ) ;
65+ } ) ;
3766
3867 it ( 'deduplicates — moves existing to front' , ( ) => {
3968 const { result } = renderHook ( ( ) => useRecentSearches ( ) ) ;
You can’t perform that action at this time.
0 commit comments