@@ -43,7 +43,7 @@ suite('Collection Documents Provider Test Suite', () => {
43
43
sinon . restore ( ) ;
44
44
} ) ;
45
45
46
- test ( 'provideTextDocumentContent parses uri and return documents in the form of a string from a find call' , ( done ) => {
46
+ test ( 'provideTextDocumentContent parses uri and return documents in the form of a string from a find call' , async ( ) => {
47
47
const mockActiveDataService = {
48
48
find : ( namespace , filter , options , callback ) : void => {
49
49
assert (
@@ -85,19 +85,15 @@ suite('Collection Documents Provider Test Suite', () => {
85
85
`scheme:Results: filename.json?namespace=my-favorite-fruit-is.pineapple&operationId=${ operationId } `
86
86
) ;
87
87
88
- testCollectionViewProvider
89
- . provideTextDocumentContent ( uri )
90
- . then ( ( documents ) => {
91
- assert (
92
- documents . includes ( 'Declaration of Independence' ) ,
93
- `Expected provideTextDocumentContent to return documents string, found ${ documents } `
94
- ) ;
95
- done ( ) ;
96
- } )
97
- . catch ( done ) ;
88
+ const documents =
89
+ await testCollectionViewProvider . provideTextDocumentContent ( uri ) ;
90
+ assert (
91
+ documents . includes ( 'Declaration of Independence' ) ,
92
+ `Expected provideTextDocumentContent to return documents string, found ${ documents } `
93
+ ) ;
98
94
} ) ;
99
95
100
- test ( 'provideTextDocumentContent returns a ejson.stringify string' , ( done ) => {
96
+ test ( 'provideTextDocumentContent returns a ejson.stringify string' , async ( ) => {
101
97
const mockDocuments = [
102
98
{
103
99
_id : 'first_id' ,
@@ -139,19 +135,16 @@ suite('Collection Documents Provider Test Suite', () => {
139
135
`scheme:Results: filename.json?namespace=test.test&operationId=${ operationId } `
140
136
) ;
141
137
142
- testCollectionViewProvider
143
- . provideTextDocumentContent ( uri )
144
- . then ( ( documents ) => {
145
- assert (
146
- documents === mockDocumentsAsJsonString ,
147
- `Expected provideTextDocumentContent to return ejson stringified string, found ${ documents } `
148
- ) ;
149
- done ( ) ;
150
- } )
151
- . catch ( done ) ;
138
+ const documents =
139
+ await testCollectionViewProvider . provideTextDocumentContent ( uri ) ;
140
+ assert . strictEqual (
141
+ documents ,
142
+ mockDocumentsAsJsonString ,
143
+ `Expected provideTextDocumentContent to return ejson stringified string, found ${ documents } `
144
+ ) ;
152
145
} ) ;
153
146
154
- test ( 'provideTextDocumentContent sets hasMoreDocumentsToShow to false when there arent more documents' , ( done ) => {
147
+ test ( 'provideTextDocumentContent sets hasMoreDocumentsToShow to false when there arent more documents' , async ( ) => {
155
148
const mockActiveDataService = {
156
149
find : ( namespace , filter , options , callback ) : void => {
157
150
return callback ( null , [ { field : 'Apollo' } , { field : 'Gemini ' } ] ) ;
@@ -185,28 +178,21 @@ suite('Collection Documents Provider Test Suite', () => {
185
178
`scheme:Results: filename.json?namespace=vostok.mercury&operationId=${ operationId } `
186
179
) ;
187
180
188
- void testCollectionViewProvider . provideTextDocumentContent ( uri ) . then ( ( ) => {
189
- assert (
190
- testQueryStore . operations [ operationId ] . hasMoreDocumentsToShow === false ,
191
- 'Expected not to have more documents to show.'
192
- ) ;
193
-
194
- // Reset and test inverse.
195
- testQueryStore . operations [ operationId ] . currentLimit = 2 ;
196
- testQueryStore . operations [ operationId ] . hasMoreDocumentsToShow = true ;
181
+ await testCollectionViewProvider . provideTextDocumentContent ( uri ) ;
182
+ assert (
183
+ testQueryStore . operations [ operationId ] . hasMoreDocumentsToShow === false ,
184
+ 'Expected not to have more documents to show.'
185
+ ) ;
197
186
198
- testCollectionViewProvider
199
- . provideTextDocumentContent ( uri )
200
- . then ( ( ) => {
201
- assert ( testQueryStore . operations [ operationId ] . hasMoreDocumentsToShow ) ;
187
+ // Reset and test inverse.
188
+ testQueryStore . operations [ operationId ] . currentLimit = 2 ;
189
+ testQueryStore . operations [ operationId ] . hasMoreDocumentsToShow = true ;
202
190
203
- done ( ) ;
204
- } )
205
- . catch ( done ) ;
206
- } ) ;
191
+ await testCollectionViewProvider . provideTextDocumentContent ( uri ) ;
192
+ assert ( testQueryStore . operations [ operationId ] . hasMoreDocumentsToShow ) ;
207
193
} ) ;
208
194
209
- test ( 'provideTextDocumentContent shows a status bar item while it is running then hide it' , ( done ) => {
195
+ test ( 'provideTextDocumentContent shows a status bar item while it is running then hide it' , async ( ) => {
210
196
const mockActiveDataService = { find : { } } as DataService ;
211
197
const mockConnectionController = new ConnectionController (
212
198
new StatusView ( mockExtensionContext ) ,
@@ -254,12 +240,8 @@ suite('Collection Documents Provider Test Suite', () => {
254
240
return callback ( null , [ { field : 'aaaaaaaaaaaaaaaaa' } ] ) ;
255
241
} ;
256
242
257
- testCollectionViewProvider
258
- . provideTextDocumentContent ( uri )
259
- . then ( ( ) => {
260
- assert ( mockHideMessage . called ) ;
261
- } )
262
- . then ( done , done ) ;
243
+ await testCollectionViewProvider . provideTextDocumentContent ( uri ) ;
244
+ assert ( mockHideMessage . called ) ;
263
245
} ) ;
264
246
265
247
test ( 'provideTextDocumentContent sets different code lenses for different namespaces from the same connection' , async ( ) => {
0 commit comments