@@ -16,7 +16,9 @@ import {
16
16
} from '../dbTestHelper' ;
17
17
import {
18
18
documentWithAllBSONTypes ,
19
- documentWithAllBsonTypesJsonified
19
+ documentWithAllBsonTypesJsonified ,
20
+ documentWithBinaryId ,
21
+ documentWithBinaryIdString
20
22
} from './documentStringFixtures' ;
21
23
22
24
const mockDocumentAsJsonString = `{
@@ -139,7 +141,7 @@ suite('Document Provider Test Suite', () => {
139
141
. then ( ( document ) => {
140
142
assert (
141
143
document === mockDocumentAsJsonString ,
142
- `Expected provideTextDocumentContent to return ejson stringified string, found ${ document } `
144
+ `Expected provideTextDocumentContent to return json stringified string, found ${ document } `
143
145
) ;
144
146
done ( ) ;
145
147
} )
@@ -212,7 +214,9 @@ suite('Document Provider Test Suite', () => {
212
214
} ) ;
213
215
214
216
test ( 'handles displaying a document with all bson types' , ( done ) => {
215
- seedDataAndCreateDataService ( 'ramen' , [ documentWithAllBSONTypes ] ) . then (
217
+ seedDataAndCreateDataService ( 'ramen' , [
218
+ documentWithAllBSONTypes
219
+ ] ) . then (
216
220
( dataService ) => {
217
221
const mockExtensionContext = new TestExtensionContext ( ) ;
218
222
const mockStorageController = new StorageController (
@@ -236,7 +240,7 @@ suite('Document Provider Test Suite', () => {
236
240
) ;
237
241
238
242
const documentId = EJSON . stringify ( {
239
- value : documentWithAllBSONTypes . _id
243
+ value : ( documentWithAllBSONTypes as any ) . _id
240
244
} ) ;
241
245
const uri = vscode . Uri . parse (
242
246
`scheme:Results: filename.json?namespace=${ TEST_DB_NAME } .ramen&documentId=${ documentId } `
@@ -247,7 +251,7 @@ suite('Document Provider Test Suite', () => {
247
251
. then ( ( document ) => {
248
252
assert (
249
253
document === documentWithAllBsonTypesJsonified ,
250
- `Expected provideTextDocumentContent to return ejson stringified string, found ${ document } `
254
+ `Expected provideTextDocumentContent to return json stringified string, found ${ document } `
251
255
) ;
252
256
done ( ) ;
253
257
} )
@@ -256,6 +260,46 @@ suite('Document Provider Test Suite', () => {
256
260
) ;
257
261
} ) ;
258
262
263
+ test ( 'can find a doc with a binary _id' , async ( ) => {
264
+ const dataService = await seedDataAndCreateDataService ( 'ramen' , [
265
+ documentWithBinaryId
266
+ ] ) ;
267
+ const mockExtensionContext = new TestExtensionContext ( ) ;
268
+ const mockStorageController = new StorageController (
269
+ mockExtensionContext
270
+ ) ;
271
+ const testTelemetryController = new TelemetryController (
272
+ mockStorageController ,
273
+ mockExtensionContext
274
+ ) ;
275
+ const mockConnectionController = new ConnectionController (
276
+ new StatusView ( mockExtensionContext ) ,
277
+ mockStorageController ,
278
+ testTelemetryController
279
+ ) ;
280
+
281
+ mockConnectionController . setActiveConnection ( dataService ) ;
282
+
283
+ const testCollectionViewProvider = new DocumentProvider (
284
+ mockConnectionController ,
285
+ new StatusView ( mockExtensionContext )
286
+ ) ;
287
+
288
+ const documentId = EJSON . stringify ( {
289
+ value : documentWithBinaryId . _id
290
+ } ) ;
291
+ const uri = vscode . Uri . parse (
292
+ `scheme:Results: filename.json?namespace=${ TEST_DB_NAME } .ramen&documentId=${ documentId } `
293
+ ) ;
294
+
295
+ const document = await testCollectionViewProvider
296
+ . provideTextDocumentContent ( uri ) ;
297
+ assert (
298
+ document === documentWithBinaryIdString ,
299
+ `Expected provideTextDocumentContent to return json stringified string ${ documentWithBinaryIdString } , found ${ document } `
300
+ ) ;
301
+ } ) ;
302
+
259
303
test ( 'expected provideTextDocumentContent to handle an id that is an object id' , ( done ) => {
260
304
const mockDocument = {
261
305
_id : new ObjectId ( '5e32b4d67bf47f4525f2f8ab' ) ,
@@ -297,7 +341,7 @@ suite('Document Provider Test Suite', () => {
297
341
. then ( ( document ) => {
298
342
assert (
299
343
document === docAsString2 ,
300
- `Expected provideTextDocumentContent to return ejson stringified string, found ${ document } `
344
+ `Expected provideTextDocumentContent to return json stringified string, found ${ document } `
301
345
) ;
302
346
done ( ) ;
303
347
} )
@@ -347,7 +391,7 @@ suite('Document Provider Test Suite', () => {
347
391
. then ( ( document ) => {
348
392
assert (
349
393
document === docAsString3 ,
350
- `Expected provideTextDocumentContent to return ejson stringified string, found ${ document } `
394
+ `Expected provideTextDocumentContent to return json stringified string, found ${ document } `
351
395
) ;
352
396
done ( ) ;
353
397
} )
0 commit comments