@@ -16,7 +16,9 @@ import {
1616} from '../dbTestHelper' ;
1717import {
1818 documentWithAllBSONTypes ,
19- documentWithAllBsonTypesJsonified
19+ documentWithAllBsonTypesJsonified ,
20+ documentWithBinaryId ,
21+ documentWithBinaryIdString
2022} from './documentStringFixtures' ;
2123
2224const mockDocumentAsJsonString = `{
@@ -139,7 +141,7 @@ suite('Document Provider Test Suite', () => {
139141 . then ( ( document ) => {
140142 assert (
141143 document === mockDocumentAsJsonString ,
142- `Expected provideTextDocumentContent to return ejson stringified string, found ${ document } `
144+ `Expected provideTextDocumentContent to return json stringified string, found ${ document } `
143145 ) ;
144146 done ( ) ;
145147 } )
@@ -212,7 +214,9 @@ suite('Document Provider Test Suite', () => {
212214 } ) ;
213215
214216 test ( 'handles displaying a document with all bson types' , ( done ) => {
215- seedDataAndCreateDataService ( 'ramen' , [ documentWithAllBSONTypes ] ) . then (
217+ seedDataAndCreateDataService ( 'ramen' , [
218+ documentWithAllBSONTypes
219+ ] ) . then (
216220 ( dataService ) => {
217221 const mockExtensionContext = new TestExtensionContext ( ) ;
218222 const mockStorageController = new StorageController (
@@ -236,7 +240,7 @@ suite('Document Provider Test Suite', () => {
236240 ) ;
237241
238242 const documentId = EJSON . stringify ( {
239- value : documentWithAllBSONTypes . _id
243+ value : ( documentWithAllBSONTypes as any ) . _id
240244 } ) ;
241245 const uri = vscode . Uri . parse (
242246 `scheme:Results: filename.json?namespace=${ TEST_DB_NAME } .ramen&documentId=${ documentId } `
@@ -247,7 +251,7 @@ suite('Document Provider Test Suite', () => {
247251 . then ( ( document ) => {
248252 assert (
249253 document === documentWithAllBsonTypesJsonified ,
250- `Expected provideTextDocumentContent to return ejson stringified string, found ${ document } `
254+ `Expected provideTextDocumentContent to return json stringified string, found ${ document } `
251255 ) ;
252256 done ( ) ;
253257 } )
@@ -256,6 +260,46 @@ suite('Document Provider Test Suite', () => {
256260 ) ;
257261 } ) ;
258262
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+
259303 test ( 'expected provideTextDocumentContent to handle an id that is an object id' , ( done ) => {
260304 const mockDocument = {
261305 _id : new ObjectId ( '5e32b4d67bf47f4525f2f8ab' ) ,
@@ -297,7 +341,7 @@ suite('Document Provider Test Suite', () => {
297341 . then ( ( document ) => {
298342 assert (
299343 document === docAsString2 ,
300- `Expected provideTextDocumentContent to return ejson stringified string, found ${ document } `
344+ `Expected provideTextDocumentContent to return json stringified string, found ${ document } `
301345 ) ;
302346 done ( ) ;
303347 } )
@@ -347,7 +391,7 @@ suite('Document Provider Test Suite', () => {
347391 . then ( ( document ) => {
348392 assert (
349393 document === docAsString3 ,
350- `Expected provideTextDocumentContent to return ejson stringified string, found ${ document } `
394+ `Expected provideTextDocumentContent to return json stringified string, found ${ document } `
351395 ) ;
352396 done ( ) ;
353397 } )
0 commit comments