@@ -21,33 +21,33 @@ describe('SecondaryAuth', function () {
2121 let onDidChangeActiveConnection : SinonStub
2222
2323 beforeEach ( async function ( ) {
24- auth = createTestAuth ( )
24+ auth = createTestAuth ( globals . globalState )
2525 sandbox = createSandbox ( )
2626 conn = await auth . createConnection ( createBuilderIdProfile ( { scopes : scopes } ) )
2727 isValid = ( conn : Connection ) : conn is Connection => {
2828 return isSsoConnection ( conn ) && hasScopes ( conn , scopes )
2929 }
30- secondaryAuth = getSecondaryAuth ( auth , 'testId' , 'testLabel' , isValid )
30+ // await globals.globalState.clear()
31+ secondaryAuth = getSecondaryAuth ( auth , 'codecatalyst' , 'testLabel' , isValid )
3132 onDidChangeActiveConnection = sandbox . stub ( )
3233 secondaryAuth . onDidChangeActiveConnection ( onDidChangeActiveConnection )
33- await globals . globalState . clear ( )
3434 } )
3535
3636 afterEach ( async function ( ) {
3737 sandbox . restore ( )
3838 } )
3939
40- it ( 'When no SecondaryAuth set or valid PrimaryAuth exist' , async function ( ) {
40+ it ( 'no SecondaryAuth set or valid PrimaryAuth exist' , async function ( ) {
4141 assert . strictEqual ( secondaryAuth . activeConnection ?. id , undefined )
4242 } )
4343
44- it ( 'When no SecondaryAuth set but valid PrimaryAuth is used' , async function ( ) {
44+ it ( 'no SecondaryAuth set but valid PrimaryAuth is used' , async function ( ) {
4545 await auth . useConnection ( conn )
4646 assert . strictEqual ( onDidChangeActiveConnection . calledOnce , true )
4747 assert . strictEqual ( secondaryAuth . activeConnection ?. id , conn . id )
4848 } )
4949
50- it ( 'When valid PrimaryAuth is set BUT SecondaryAuth is already using the same connection' , async function ( ) {
50+ it ( 'valid PrimaryAuth is set BUT SecondaryAuth is already using the same connection' , async function ( ) {
5151 await secondaryAuth . useNewConnection ( conn )
5252 // we save this connection so we expect it to trigger an event
5353 assert . strictEqual ( onDidChangeActiveConnection . called , true )
@@ -60,7 +60,7 @@ describe('SecondaryAuth', function () {
6060 assert . strictEqual ( secondaryAuth . activeConnection ?. id , conn . id )
6161 } )
6262
63- it ( 'When valid PrimaryAuth changes BUT no SecondaryAuth is set + valid PrimaryAuth currently exists' , async function ( ) {
63+ it ( 'valid PrimaryAuth changes BUT SecondaryAuth not set + valid PrimaryAuth exists' , async function ( ) {
6464 // Make primary auth already exist
6565 await auth . useConnection ( conn )
6666 assert . strictEqual ( onDidChangeActiveConnection . called , true )
@@ -74,7 +74,7 @@ describe('SecondaryAuth', function () {
7474 assert . strictEqual ( secondaryAuth . activeConnection ?. id , otherValidConn . id )
7575 } )
7676
77- it ( 'When valid PrimaryAuth deleted BUT SecondaryAuth is already set' , async function ( ) {
77+ it ( 'valid PrimaryAuth deleted BUT SecondaryAuth is set' , async function ( ) {
7878 await secondaryAuth . useNewConnection ( conn )
7979
8080 // add valid connection to the PrimaryAuth
@@ -89,7 +89,7 @@ describe('SecondaryAuth', function () {
8989 assert . strictEqual ( secondaryAuth . activeConnection ?. id , conn . id )
9090 } )
9191
92- it ( 'When valid SecondaryAuth deleted BUT valid PrimaryAuth already exists' , async function ( ) {
92+ it ( 'valid SecondaryAuth deleted BUT valid PrimaryAuth exists' , async function ( ) {
9393 await secondaryAuth . useNewConnection ( conn )
9494
9595 // add valid connection to the PrimaryAuth
@@ -101,11 +101,21 @@ describe('SecondaryAuth', function () {
101101 await auth . deleteConnection ( conn )
102102
103103 // we fallback to the PrimaryAuth connection
104- assert . strictEqual ( secondaryAuth . activeConnection ?. id , otherConn . id )
105104 assert . strictEqual ( onDidChangeActiveConnection . called , true )
105+ assert . deepStrictEqual (
106+ {
107+ id : secondaryAuth . activeConnection ?. id ,
108+ label : secondaryAuth . activeConnection ?. label ,
109+ } ,
110+ {
111+ id : otherConn . id ,
112+ label : otherConn . label ,
113+ }
114+ )
115+ assert . strictEqual ( secondaryAuth . activeConnection ?. id , otherConn . id )
106116 } )
107117
108- it ( 'When SecondaryAuth is invalid, but is reauthenticated elsewhere' , async function ( ) {
118+ it ( 'SecondaryAuth is invalid, but is reauthenticated elsewhere' , async function ( ) {
109119 // PrimaryAuth has its own conn, we don't care about this
110120 await auth . useConnection ( conn )
111121
0 commit comments