@@ -108,7 +108,6 @@ function testSearch({
108
108
return ;
109
109
}
110
110
eventBus . off ( "updatefindmatchescount" , onUpdateFindMatchesCount ) ;
111
-
112
111
expect ( evt . matchesCount . total ) . toBe ( totalMatches ) ;
113
112
for ( let i = 0 ; i < totalPages ; i ++ ) {
114
113
expect ( pdfFindController . pageMatches [ i ] . length ) . toEqual (
@@ -271,5 +270,130 @@ describe("pdf_find_controller", function () {
271
270
pageMatches : [ [ 19 , 48 , 66 ] ] ,
272
271
pageMatchesLength : [ [ 8 , 8 , 8 ] ] ,
273
272
} ) ;
273
+
274
+ await testSearch ( {
275
+ eventBus,
276
+ pdfFindController,
277
+ parameters : {
278
+ query : "1/2" ,
279
+ caseSensitive : false ,
280
+ entireWord : false ,
281
+ phraseSearch : true ,
282
+ findPrevious : false ,
283
+ } ,
284
+ matchesPerPage : [ 2 ] ,
285
+ selectedMatch : {
286
+ pageIndex : 0 ,
287
+ matchIndex : 0 ,
288
+ } ,
289
+ pageMatches : [ [ 28 , 57 ] ] ,
290
+ pageMatchesLength : [ [ 1 , 1 ] ] ,
291
+ } ) ;
292
+
293
+ await testSearch ( {
294
+ eventBus,
295
+ pdfFindController,
296
+ parameters : {
297
+ query : "½" ,
298
+ caseSensitive : false ,
299
+ entireWord : false ,
300
+ phraseSearch : true ,
301
+ findPrevious : false ,
302
+ } ,
303
+ matchesPerPage : [ 2 ] ,
304
+ selectedMatch : {
305
+ pageIndex : 0 ,
306
+ matchIndex : 0 ,
307
+ } ,
308
+ pageMatches : [ [ 28 , 57 ] ] ,
309
+ pageMatchesLength : [ [ 1 , 1 ] ] ,
310
+ } ) ;
311
+ } ) ;
312
+
313
+ it ( "performs a normal search, where the text with diacritics is normalized" , async function ( ) {
314
+ const { eventBus, pdfFindController } = await initPdfFindController (
315
+ "french_diacritics.pdf"
316
+ ) ;
317
+
318
+ await testSearch ( {
319
+ eventBus,
320
+ pdfFindController,
321
+ parameters : {
322
+ query : "a" ,
323
+ caseSensitive : false ,
324
+ entireWord : false ,
325
+ phraseSearch : true ,
326
+ findPrevious : false ,
327
+ matchDiacritics : false ,
328
+ } ,
329
+ matchesPerPage : [ 6 ] ,
330
+ selectedMatch : {
331
+ pageIndex : 0 ,
332
+ matchIndex : 0 ,
333
+ } ,
334
+ pageMatches : [ [ 0 , 2 , 4 , 6 , 8 , 10 ] ] ,
335
+ pageMatchesLength : [ [ 1 , 1 , 1 , 1 , 1 , 1 ] ] ,
336
+ } ) ;
337
+
338
+ await testSearch ( {
339
+ eventBus,
340
+ pdfFindController,
341
+ parameters : {
342
+ query : "u" ,
343
+ caseSensitive : false ,
344
+ entireWord : false ,
345
+ phraseSearch : true ,
346
+ findPrevious : false ,
347
+ matchDiacritics : false ,
348
+ } ,
349
+ matchesPerPage : [ 6 ] ,
350
+ selectedMatch : {
351
+ pageIndex : 0 ,
352
+ matchIndex : 0 ,
353
+ } ,
354
+ pageMatches : [ [ 44 , 46 , 48 , 50 , 52 , 54 ] ] ,
355
+ pageMatchesLength : [ [ 1 , 1 , 1 , 1 , 1 , 1 ] ] ,
356
+ } ) ;
357
+
358
+ await testSearch ( {
359
+ eventBus,
360
+ pdfFindController,
361
+ parameters : {
362
+ query : "ë" ,
363
+ caseSensitive : false ,
364
+ entireWord : false ,
365
+ phraseSearch : true ,
366
+ findPrevious : false ,
367
+ matchDiacritics : true ,
368
+ } ,
369
+ matchesPerPage : [ 2 ] ,
370
+ selectedMatch : {
371
+ pageIndex : 0 ,
372
+ matchIndex : 0 ,
373
+ } ,
374
+ pageMatches : [ [ 28 , 30 ] ] ,
375
+ pageMatchesLength : [ [ 1 , 1 ] ] ,
376
+ } ) ;
377
+ } ) ;
378
+
379
+ it ( "performs a search where one of the results contains an hyphen" , async function ( ) {
380
+ const { eventBus, pdfFindController } = await initPdfFindController ( ) ;
381
+
382
+ await testSearch ( {
383
+ eventBus,
384
+ pdfFindController,
385
+ parameters : {
386
+ query : "optimiz" ,
387
+ caseSensitive : false ,
388
+ entireWord : false ,
389
+ phraseSearch : true ,
390
+ findPrevious : false ,
391
+ } ,
392
+ matchesPerPage : [ 1 , 4 , 2 , 3 , 3 , 0 , 2 , 9 , 1 , 0 , 0 , 6 , 3 , 4 ] ,
393
+ selectedMatch : {
394
+ pageIndex : 0 ,
395
+ matchIndex : 0 ,
396
+ } ,
397
+ } ) ;
274
398
} ) ;
275
399
} ) ;
0 commit comments