@@ -21,33 +21,33 @@ describe('SecondaryAuth', function () {
21
21
let onDidChangeActiveConnection : SinonStub
22
22
23
23
beforeEach ( async function ( ) {
24
- auth = createTestAuth ( )
24
+ auth = createTestAuth ( globals . globalState )
25
25
sandbox = createSandbox ( )
26
26
conn = await auth . createConnection ( createBuilderIdProfile ( { scopes : scopes } ) )
27
27
isValid = ( conn : Connection ) : conn is Connection => {
28
28
return isSsoConnection ( conn ) && hasScopes ( conn , scopes )
29
29
}
30
- secondaryAuth = getSecondaryAuth ( auth , 'testId' , 'testLabel' , isValid )
30
+ // await globals.globalState.clear()
31
+ secondaryAuth = getSecondaryAuth ( auth , 'codecatalyst' , 'testLabel' , isValid )
31
32
onDidChangeActiveConnection = sandbox . stub ( )
32
33
secondaryAuth . onDidChangeActiveConnection ( onDidChangeActiveConnection )
33
- await globals . globalState . clear ( )
34
34
} )
35
35
36
36
afterEach ( async function ( ) {
37
37
sandbox . restore ( )
38
38
} )
39
39
40
- it ( 'When no SecondaryAuth set or valid PrimaryAuth exist' , async function ( ) {
40
+ it ( 'no SecondaryAuth set or valid PrimaryAuth exist' , async function ( ) {
41
41
assert . strictEqual ( secondaryAuth . activeConnection ?. id , undefined )
42
42
} )
43
43
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 ( ) {
45
45
await auth . useConnection ( conn )
46
46
assert . strictEqual ( onDidChangeActiveConnection . calledOnce , true )
47
47
assert . strictEqual ( secondaryAuth . activeConnection ?. id , conn . id )
48
48
} )
49
49
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 ( ) {
51
51
await secondaryAuth . useNewConnection ( conn )
52
52
// we save this connection so we expect it to trigger an event
53
53
assert . strictEqual ( onDidChangeActiveConnection . called , true )
@@ -60,7 +60,7 @@ describe('SecondaryAuth', function () {
60
60
assert . strictEqual ( secondaryAuth . activeConnection ?. id , conn . id )
61
61
} )
62
62
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 ( ) {
64
64
// Make primary auth already exist
65
65
await auth . useConnection ( conn )
66
66
assert . strictEqual ( onDidChangeActiveConnection . called , true )
@@ -74,7 +74,7 @@ describe('SecondaryAuth', function () {
74
74
assert . strictEqual ( secondaryAuth . activeConnection ?. id , otherValidConn . id )
75
75
} )
76
76
77
- it ( 'When valid PrimaryAuth deleted BUT SecondaryAuth is already set' , async function ( ) {
77
+ it ( 'valid PrimaryAuth deleted BUT SecondaryAuth is set' , async function ( ) {
78
78
await secondaryAuth . useNewConnection ( conn )
79
79
80
80
// add valid connection to the PrimaryAuth
@@ -89,7 +89,7 @@ describe('SecondaryAuth', function () {
89
89
assert . strictEqual ( secondaryAuth . activeConnection ?. id , conn . id )
90
90
} )
91
91
92
- it ( 'When valid SecondaryAuth deleted BUT valid PrimaryAuth already exists' , async function ( ) {
92
+ it ( 'valid SecondaryAuth deleted BUT valid PrimaryAuth exists' , async function ( ) {
93
93
await secondaryAuth . useNewConnection ( conn )
94
94
95
95
// add valid connection to the PrimaryAuth
@@ -101,11 +101,21 @@ describe('SecondaryAuth', function () {
101
101
await auth . deleteConnection ( conn )
102
102
103
103
// we fallback to the PrimaryAuth connection
104
- assert . strictEqual ( secondaryAuth . activeConnection ?. id , otherConn . id )
105
104
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 )
106
116
} )
107
117
108
- it ( 'When SecondaryAuth is invalid, but is reauthenticated elsewhere' , async function ( ) {
118
+ it ( 'SecondaryAuth is invalid, but is reauthenticated elsewhere' , async function ( ) {
109
119
// PrimaryAuth has its own conn, we don't care about this
110
120
await auth . useConnection ( conn )
111
121
0 commit comments