Skip to content

Commit bc7df5c

Browse files
committed
Add unit test for AuthUtil
1 parent 0b75f3b commit bc7df5c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

packages/amazonq/test/unit/codewhisperer/util/authUtil.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,34 @@ describe('AuthUtil', async function () {
140140
})
141141
})
142142

143+
describe('cacheChangedHandler', function () {
144+
it('calls logout when event is delete', async function () {
145+
const logoutSpy = sinon.spy(auth, 'logout')
146+
147+
await (auth as any).cacheChangedHandler('delete')
148+
149+
assert.ok(logoutSpy.calledOnce)
150+
})
151+
152+
it('calls restore when event is create', async function () {
153+
const restoreSpy = sinon.spy(auth, 'restore')
154+
155+
await (auth as any).cacheChangedHandler('create')
156+
157+
assert.ok(restoreSpy.calledOnce)
158+
})
159+
160+
it('does nothing for other events', async function () {
161+
const logoutSpy = sinon.spy(auth, 'logout')
162+
const restoreSpy = sinon.spy(auth, 'restore')
163+
164+
await (auth as any).cacheChangedHandler('unknown')
165+
166+
assert.ok(logoutSpy.notCalled)
167+
assert.ok(restoreSpy.notCalled)
168+
})
169+
})
170+
143171
describe('stateChangeHandler', function () {
144172
let mockLspAuth: any
145173
let regionProfileManager: any

0 commit comments

Comments
 (0)