@@ -235,6 +235,71 @@ suite('Explorer Controller Test Suite', function () {
235235 }
236236 } ) ;
237237
238+ test ( 'shows connection names sorted alphabetically in the tree' , async ( ) => {
239+ const testConnectionController =
240+ mdbTestExtension . testExtensionController . _connectionController ;
241+ const testExplorerController =
242+ mdbTestExtension . testExtensionController . _explorerController ;
243+ const treeController = testExplorerController . getTreeController ( ) ;
244+
245+ try {
246+ await testConnectionController . addNewConnectionStringAndConnect (
247+ TEST_DATABASE_URI
248+ ) ;
249+ } catch ( error ) {
250+ assert ( false ) ;
251+ }
252+
253+ const connectionId =
254+ testConnectionController . getActiveConnectionId ( ) || '' ;
255+
256+ testConnectionController . _connections . aaa = {
257+ connectionModel : testConnectionController . _connections [ connectionId ] . connectionModel ,
258+ driverUrl : '' ,
259+ name : 'aaa' ,
260+ id : 'aaa' ,
261+ storageLocation : StorageScope . WORKSPACE
262+ } ;
263+
264+ testConnectionController . _connections . zzz = {
265+ connectionModel : testConnectionController . _connections [ connectionId ] . connectionModel ,
266+ driverUrl : '' ,
267+ name : 'zzz' ,
268+ id : 'zzz' ,
269+ storageLocation : StorageScope . WORKSPACE
270+ } ;
271+
272+ try {
273+ const treeControllerChildren = await treeController . getChildren ( ) ;
274+ const connectionsItems = await treeControllerChildren [ 0 ] . getChildren ( ) ;
275+
276+ assert (
277+ connectionsItems . length === 3 ,
278+ `Expected there be 3 connection tree item, found ${ connectionsItems . length } `
279+ ) ;
280+ assert (
281+ connectionsItems [ 0 ] . label === 'aaa' ,
282+ `First connection tree item should have label "aaa" found ${ connectionsItems [ 0 ] . label } `
283+ ) ;
284+ assert (
285+ connectionsItems [ 2 ] . label === 'zzz' ,
286+ `First connection tree item should have label "zzz" found ${ connectionsItems [ 0 ] . label } `
287+ ) ;
288+
289+ testConnectionController . _connections . zzz . name = '111' ;
290+
291+ const afterAdditionConnectionsItems = await treeControllerChildren [ 0 ] . getChildren ( ) ;
292+ assert (
293+ afterAdditionConnectionsItems [ 0 ] . label === '111' ,
294+ `First connection tree item should have label "111" found ${ afterAdditionConnectionsItems [ 0 ] . label } `
295+ ) ;
296+
297+ testExplorerController . deactivate ( ) ;
298+ } catch ( error ) {
299+ assert ( false , error ) ;
300+ }
301+ } ) ;
302+
238303 test ( 'shows the databases of connected connection in tree' , async ( ) => {
239304 const testConnectionController =
240305 mdbTestExtension . testExtensionController . _connectionController ;
0 commit comments