@@ -118,4 +118,54 @@ describe('useTextAnalyzer', () => {
118118 leastFrequentCharacter : '!' ,
119119 } ) ;
120120 } ) ;
121+
122+ it ( 'should analyze text correctly with searchTerm and when wordsPerMinute is string' , ( ) => {
123+ const { result } = renderHook ( ( ) =>
124+ // @ts -expect-error edge case when wordsPerMinute is a string
125+ useTextAnalyzer ( { text : text . trim ( ) , searchTerm : 'SeCoNd' , ignoreCase : true , wordsPerMinute : '250' } ) ,
126+ ) ;
127+
128+ expect ( result . current ) . toEqual ( {
129+ wordCount : 78 ,
130+ charCount : 560 ,
131+ sentenceCount : 14 ,
132+ paragraphCount : 7 ,
133+ searchFrequency : 2 ,
134+ readingTime : {
135+ minutes : 0 ,
136+ seconds : 19 ,
137+ total : 19 ,
138+ text : 'less than a minute read' ,
139+ } ,
140+ mostFrequentWord : 'paragraph' ,
141+ leastFrequentWord : 'first' ,
142+ mostFrequentCharacter : 'a' ,
143+ leastFrequentCharacter : '!' ,
144+ } ) ;
145+ } ) ;
146+
147+ it ( 'should analyze text correctly with searchTerm and when wordsPerMinute is empty string' , ( ) => {
148+ const { result } = renderHook ( ( ) =>
149+ // @ts -expect-error edge case when wordsPerMinute is a string
150+ useTextAnalyzer ( { text : text . trim ( ) , searchTerm : 'SeCoNd' , ignoreCase : true , wordsPerMinute : '' } ) ,
151+ ) ;
152+
153+ expect ( result . current ) . toEqual ( {
154+ wordCount : 78 ,
155+ charCount : 560 ,
156+ sentenceCount : 14 ,
157+ paragraphCount : 7 ,
158+ searchFrequency : 2 ,
159+ readingTime : {
160+ minutes : 0 ,
161+ seconds : 19 ,
162+ total : 19 ,
163+ text : 'less than a minute read' ,
164+ } ,
165+ mostFrequentWord : 'paragraph' ,
166+ leastFrequentWord : 'first' ,
167+ mostFrequentCharacter : 'a' ,
168+ leastFrequentCharacter : '!' ,
169+ } ) ;
170+ } ) ;
121171} ) ;
0 commit comments