Skip to content

Commit 6fc43d6

Browse files
committed
chore: fix node test
1 parent 733b033 commit 6fc43d6

1 file changed

Lines changed: 30 additions & 29 deletions

File tree

packages/search/__tests__/node/content-search.service.test.ts

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { SearchModule } from '../../src/node';
1717

1818
// Allow creating temporary files, but remove them when we are done.
1919
const track = temp.track();
20+
let searchId = new Date().getTime();
2021

2122
// The root dirs we'll use to test searching.
2223
let rootDirA: string;
@@ -258,7 +259,7 @@ describe('ripgrep-search-in-workspace-server', () => {
258259
done();
259260
});
260261
(contentSearchServer as any).rpcClient = [client];
261-
contentSearchServer.search(pattern, [rootDirAUri]);
262+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
262263
});
263264

264265
it('should return 1 result when searching for "pasta", respecting the trailing whitespace', (done) => {
@@ -272,7 +273,7 @@ describe('ripgrep-search-in-workspace-server', () => {
272273
done();
273274
});
274275
(contentSearchServer as any).rpcClient = [client];
275-
contentSearchServer.search(pattern, [rootDirAUri]);
276+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
276277
});
277278

278279
// Try some simple patterns with different case.
@@ -293,7 +294,7 @@ describe('ripgrep-search-in-workspace-server', () => {
293294
done();
294295
});
295296
(contentSearchServer as any).rpcClient = [client];
296-
contentSearchServer.search(pattern, [rootDirAUri]);
297+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
297298
});
298299

299300
it('should return 5 results when searching for "carrot" case sensitive', (done) => {
@@ -312,7 +313,7 @@ describe('ripgrep-search-in-workspace-server', () => {
312313
done();
313314
});
314315
(contentSearchServer as any).rpcClient = [client];
315-
contentSearchServer.search(pattern, [rootDirAUri], {
316+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], {
316317
matchCase: true,
317318
});
318319
});
@@ -332,7 +333,7 @@ describe('ripgrep-search-in-workspace-server', () => {
332333
done();
333334
});
334335
(contentSearchServer as any).rpcClient = [client];
335-
contentSearchServer.search(pattern, [rootDirAUri], {
336+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], {
336337
matchWholeWord: true,
337338
});
338339
});
@@ -350,7 +351,7 @@ describe('ripgrep-search-in-workspace-server', () => {
350351
done();
351352
});
352353
(contentSearchServer as any).rpcClient = [client];
353-
contentSearchServer.search(pattern, [rootDirAUri], {
354+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], {
354355
matchWholeWord: true,
355356
matchCase: true,
356357
});
@@ -366,7 +367,7 @@ describe('ripgrep-search-in-workspace-server', () => {
366367
done();
367368
});
368369
(contentSearchServer as any).rpcClient = [client];
369-
contentSearchServer.search('Carrot', [rootDirAUri], { matchCase: true });
370+
contentSearchServer.search(searchId++, 'Carrot', [rootDirAUri], { matchCase: true });
370371
});
371372

372373
it('should return 0 result when searching for "CarroT"', (done) => {
@@ -377,7 +378,7 @@ describe('ripgrep-search-in-workspace-server', () => {
377378
done();
378379
});
379380
(contentSearchServer as any).rpcClient = [client];
380-
contentSearchServer.search(pattern, [rootDirAUri], { matchCase: true });
381+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { matchCase: true });
381382
});
382383

383384
// Try something that we know isn't there.
@@ -389,7 +390,7 @@ describe('ripgrep-search-in-workspace-server', () => {
389390
done();
390391
});
391392
(contentSearchServer as any).rpcClient = [client];
392-
contentSearchServer.search(pattern, [rootDirAUri]);
393+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
393394
});
394395

395396
// Try a pattern with a space.
@@ -405,7 +406,7 @@ describe('ripgrep-search-in-workspace-server', () => {
405406
done();
406407
});
407408
(contentSearchServer as any).rpcClient = [client];
408-
contentSearchServer.search(pattern, [rootDirAUri]);
409+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
409410
});
410411

411412
// Try with an output size that exceeds the default node buffer size
@@ -433,7 +434,7 @@ describe('ripgrep-search-in-workspace-server', () => {
433434
});
434435

435436
(contentSearchServer as any).rpcClient = [client];
436-
contentSearchServer.search(pattern, [rootDirAUri]);
437+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
437438
});
438439

439440
// Try limiting the number of returned results.
@@ -458,7 +459,7 @@ describe('ripgrep-search-in-workspace-server', () => {
458459
});
459460

460461
(contentSearchServer as any).rpcClient = [client];
461-
contentSearchServer.search(pattern, [rootDirAUri], {
462+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], {
462463
maxResults: 1000,
463464
});
464465
});
@@ -480,7 +481,7 @@ describe('ripgrep-search-in-workspace-server', () => {
480481
done();
481482
});
482483
(contentSearchServer as any).rpcClient = [client];
483-
contentSearchServer.search(pattern, [rootDirAUri], {
484+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], {
484485
useRegExp: true,
485486
});
486487
});
@@ -498,7 +499,7 @@ describe('ripgrep-search-in-workspace-server', () => {
498499
done();
499500
});
500501
(contentSearchServer as any).rpcClient = [client];
501-
contentSearchServer.search(pattern, [rootDirAUri], {
502+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], {
502503
useRegExp: false,
503504
});
504505
});
@@ -520,7 +521,7 @@ describe('ripgrep-search-in-workspace-server', () => {
520521
done();
521522
});
522523
(contentSearchServer as any).rpcClient = [client];
523-
contentSearchServer.search(pattern, [rootDirAUri], { useRegExp: true });
524+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { useRegExp: true });
524525
});
525526

526527
// Try with a pattern starting with --, and in filenames containing colons and spaces.
@@ -540,7 +541,7 @@ describe('ripgrep-search-in-workspace-server', () => {
540541
done();
541542
});
542543
(contentSearchServer as any).rpcClient = [client];
543-
contentSearchServer.search(pattern, [rootDirAUri], { useRegExp: true });
544+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { useRegExp: true });
544545
});
545546

546547
it('should search a pattern starting with a dash w/o regex', (done) => {
@@ -559,7 +560,7 @@ describe('ripgrep-search-in-workspace-server', () => {
559560
done();
560561
});
561562
(contentSearchServer as any).rpcClient = [client];
562-
contentSearchServer.search(pattern, [rootDirAUri]);
563+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
563564
});
564565

565566
it('should search a pattern starting with two dashes w/o regex', (done) => {
@@ -578,7 +579,7 @@ describe('ripgrep-search-in-workspace-server', () => {
578579
done();
579580
});
580581
(contentSearchServer as any).rpcClient = [client];
581-
contentSearchServer.search(pattern, [rootDirAUri]);
582+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
582583
});
583584

584585
it('should search a whole pattern starting with - w/o regex', (done) => {
@@ -594,7 +595,7 @@ describe('ripgrep-search-in-workspace-server', () => {
594595
done();
595596
});
596597
(contentSearchServer as any).rpcClient = [client];
597-
contentSearchServer.search(pattern, [rootDirAUri], { matchWholeWord: true });
598+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { matchWholeWord: true });
598599
});
599600

600601
it('should search a whole pattern starting with -- w/o regex', (done) => {
@@ -609,7 +610,7 @@ describe('ripgrep-search-in-workspace-server', () => {
609610
done();
610611
});
611612
(contentSearchServer as any).rpcClient = [client];
612-
contentSearchServer.search(pattern, [rootDirAUri], { matchWholeWord: true });
613+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { matchWholeWord: true });
613614
});
614615

615616
it('should search a pattern in .txt file', (done) => {
@@ -624,7 +625,7 @@ describe('ripgrep-search-in-workspace-server', () => {
624625
done();
625626
});
626627
(contentSearchServer as any).rpcClient = [client];
627-
contentSearchServer.search(pattern, [rootDirAUri], { include: ['*.txt'] });
628+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { include: ['*.txt'] });
628629
});
629630

630631
it('should search a whole pattern in .txt file', (done) => {
@@ -639,7 +640,7 @@ describe('ripgrep-search-in-workspace-server', () => {
639640
done();
640641
});
641642
(contentSearchServer as any).rpcClient = [client];
642-
contentSearchServer.search(pattern, [rootDirAUri], { include: ['*.txt'], matchWholeWord: true });
643+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { include: ['*.txt'], matchWholeWord: true });
643644
});
644645

645646
// Try searching in an UTF-8 file.
@@ -656,7 +657,7 @@ describe('ripgrep-search-in-workspace-server', () => {
656657
done();
657658
});
658659
(contentSearchServer as any).rpcClient = [client];
659-
contentSearchServer.search(pattern, [rootDirAUri]);
660+
contentSearchServer.search(searchId++, pattern, [rootDirAUri]);
660661
});
661662

662663
// Try searching a pattern that contains unicode matchStarts.
@@ -674,7 +675,7 @@ describe('ripgrep-search-in-workspace-server', () => {
674675
done();
675676
});
676677
(contentSearchServer as any).rpcClient = [client];
677-
contentSearchServer.search(pattern, [rootDirAUri], { useRegExp: true });
678+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { useRegExp: true });
678679
});
679680

680681
// A regex that may match an empty string should not return zero-length
@@ -690,7 +691,7 @@ describe('ripgrep-search-in-workspace-server', () => {
690691
done();
691692
});
692693
(contentSearchServer as any).rpcClient = [client];
693-
contentSearchServer.search(pattern, [rootDirAUri + '/small']);
694+
contentSearchServer.search(searchId++, pattern, [rootDirAUri + '/small']);
694695
});
695696

696697
it('should search a pattern with special matchStarts ', (done) => {
@@ -705,7 +706,7 @@ describe('ripgrep-search-in-workspace-server', () => {
705706
done();
706707
});
707708
(contentSearchServer as any).rpcClient = [client];
708-
contentSearchServer.search(pattern, [rootDirAUri], { useRegExp: true });
709+
contentSearchServer.search(searchId++, pattern, [rootDirAUri], { useRegExp: true });
709710
});
710711

711712
it('should find patterns across all directories', (done) => {
@@ -727,7 +728,7 @@ describe('ripgrep-search-in-workspace-server', () => {
727728
done();
728729
});
729730
(contentSearchServer as any).rpcClient = [client];
730-
contentSearchServer.search(pattern, [rootDirAUri, rootDirBUri]);
731+
contentSearchServer.search(searchId++, pattern, [rootDirAUri, rootDirBUri]);
731732
});
732733

733734
it('should only find patterns from the folder closest to the file', (done) => {
@@ -745,10 +746,10 @@ describe('ripgrep-search-in-workspace-server', () => {
745746
done();
746747
});
747748
(contentSearchServer as any).rpcClient = [client];
748-
contentSearchServer.search(pattern, [rootDirAUri, rootSubdirAUri]);
749+
contentSearchServer.search(searchId++, pattern, [rootDirAUri, rootSubdirAUri]);
749750
});
750751

751-
it('出错时可以正常抛出', (done) => {
752+
it('thrrow error', (done) => {
752753
const errorMessage = 'A error!';
753754
const id = 9;
754755

0 commit comments

Comments
 (0)