@@ -60,7 +60,6 @@ const lineOneRange = new OneLineRange(1, 0, 1);
60
60
suite ( 'SearchModel' , ( ) => {
61
61
62
62
let instantiationService : TestInstantiationService ;
63
- let restoreStubs : sinon . SinonStub [ ] ;
64
63
65
64
const testSearchStats : IFileSearchStats = {
66
65
fromCache : false ,
@@ -80,7 +79,6 @@ suite('SearchModel', () => {
80
79
] ;
81
80
82
81
setup ( ( ) => {
83
- restoreStubs = [ ] ;
84
82
instantiationService = new TestInstantiationService ( ) ;
85
83
instantiationService . stub ( ITelemetryService , NullTelemetryService ) ;
86
84
instantiationService . stub ( ILabelService , { getUriBasenameLabel : ( uri : URI ) => '' } ) ;
@@ -92,11 +90,7 @@ suite('SearchModel', () => {
92
90
instantiationService . stub ( ILogService , new NullLogService ( ) ) ;
93
91
} ) ;
94
92
95
- teardown ( ( ) => {
96
- restoreStubs . forEach ( element => {
97
- element . restore ( ) ;
98
- } ) ;
99
- } ) ;
93
+ teardown ( ( ) => sinon . restore ( ) ) ;
100
94
101
95
function searchServiceWithResults ( results : IFileMatch [ ] , complete : ISearchComplete | null = null ) : ISearchService {
102
96
return < ISearchService > {
@@ -174,8 +168,7 @@ suite('SearchModel', () => {
174
168
new TextSearchMatch ( 'this is a test' , new OneLineRange ( 1 , 11 , 15 ) ) ) ,
175
169
aRawMatch ( '/3' , new TextSearchMatch ( 'test' , lineOneRange ) ) ] ;
176
170
const searchService = instantiationService . stub ( ISearchService , searchServiceWithResults ( results ) ) ;
177
- const addContext = sinon . stub ( CellMatch . prototype , 'addContext' ) ;
178
- restoreStubs . push ( addContext ) ;
171
+ sinon . stub ( CellMatch . prototype , 'addContext' ) ;
179
172
180
173
const textSearch = sinon . spy ( searchService , 'textSearch' ) ;
181
174
const mdInputCell = {
@@ -264,8 +257,6 @@ suite('SearchModel', () => {
264
257
scannedFiles : new ResourceSet ( [ ...localResults . keys ( ) ] ) ,
265
258
} ) ;
266
259
} ) ;
267
- restoreStubs . push ( notebookSearch ) ;
268
-
269
260
270
261
await model . search ( { contentPattern : { pattern : 'test' } , type : QueryType . Text , folderQueries } ) ;
271
262
const actual = model . searchResult . matches ( ) ;
@@ -329,7 +320,7 @@ suite('SearchModel', () => {
329
320
330
321
test ( 'Search Model: Search reports timed telemetry on search when progress is not called' , ( ) => {
331
322
const target2 = sinon . spy ( ) ;
332
- stub ( nullEvent , 'stop' , target2 ) ;
323
+ sinon . stub ( nullEvent , 'stop' ) . callsFake ( target2 ) ;
333
324
const target1 = sinon . stub ( ) . returns ( nullEvent ) ;
334
325
instantiationService . stub ( ITelemetryService , 'publicLog' , target1 ) ;
335
326
@@ -348,7 +339,7 @@ suite('SearchModel', () => {
348
339
349
340
test ( 'Search Model: Search reports timed telemetry on search when progress is called' , ( ) => {
350
341
const target2 = sinon . spy ( ) ;
351
- stub ( nullEvent , 'stop' , target2 ) ;
342
+ sinon . stub ( nullEvent , 'stop' ) . callsFake ( target2 ) ;
352
343
const target1 = sinon . stub ( ) . returns ( nullEvent ) ;
353
344
instantiationService . stub ( ITelemetryService , 'publicLog' , target1 ) ;
354
345
@@ -372,7 +363,7 @@ suite('SearchModel', () => {
372
363
373
364
test ( 'Search Model: Search reports timed telemetry on search when error is called' , ( ) => {
374
365
const target2 = sinon . spy ( ) ;
375
- stub ( nullEvent , 'stop' , target2 ) ;
366
+ sinon . stub ( nullEvent , 'stop' ) . callsFake ( target2 ) ;
376
367
const target1 = sinon . stub ( ) . returns ( nullEvent ) ;
377
368
instantiationService . stub ( ITelemetryService , 'publicLog' , target1 ) ;
378
369
@@ -392,7 +383,7 @@ suite('SearchModel', () => {
392
383
393
384
test ( 'Search Model: Search reports timed telemetry on search when error is cancelled error' , ( ) => {
394
385
const target2 = sinon . spy ( ) ;
395
- stub ( nullEvent , 'stop' , target2 ) ;
386
+ sinon . stub ( nullEvent , 'stop' ) . callsFake ( target2 ) ;
396
387
const target1 = sinon . stub ( ) . returns ( nullEvent ) ;
397
388
instantiationService . stub ( ITelemetryService , 'publicLog' , target1 ) ;
398
389
@@ -491,12 +482,6 @@ suite('SearchModel', () => {
491
482
return { resource : createFileUriFromPathFromRoot ( resource ) , cellResults : cells } ;
492
483
}
493
484
494
- function stub ( arg1 : any , arg2 : any , arg3 : any ) : sinon . SinonStub {
495
- const stub = sinon . stub ( arg1 , arg2 ) . callsFake ( arg3 ) ;
496
- restoreStubs . push ( stub ) ;
497
- return stub ;
498
- }
499
-
500
485
function stubModelService ( instantiationService : TestInstantiationService ) : IModelService {
501
486
instantiationService . stub ( IThemeService , new TestThemeService ( ) ) ;
502
487
const config = new TestConfigurationService ( ) ;
0 commit comments