Skip to content

Commit 0eafb3f

Browse files
test(amazonq): small improvement to developer profiles test
1 parent 0435c80 commit 0eafb3f

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/qDeveloperProfiles.test.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as assert from 'assert'
2-
import { StubbedInstance, stubInterface } from 'ts-sinon'
2+
import sinon, { StubbedInstance, stubInterface } from 'ts-sinon'
33
import { CodeWhispererServiceToken } from '../codeWhispererService'
44
import { SsoConnectionType } from '../utils'
55
import { AWSInitializationOptions, Logging } from '@aws/language-server-runtimes/server-interface'
@@ -46,11 +46,6 @@ describe('ListAllAvailableProfiles Handler', () => {
4646
$response: {} as any,
4747
}
4848

49-
const listAvailableProfilesResponseWithNextToken = {
50-
...listAvailableProfilesResponse,
51-
nextToken: 'some-random-next-token',
52-
}
53-
5449
beforeEach(() => {
5550
logging = stubInterface<Logging>()
5651
codeWhispererService = stubInterface<CodeWhispererServiceToken>()
@@ -86,6 +81,12 @@ describe('ListAllAvailableProfiles Handler', () => {
8681

8782
describe('Pagination', () => {
8883
const MAX_EXPECTED_PAGES = 10
84+
const SOME_NEXT_TOKEN = 'some-random-next-token'
85+
86+
const listAvailableProfilesResponseWithNextToken = {
87+
...listAvailableProfilesResponse,
88+
nextToken: SOME_NEXT_TOKEN,
89+
}
8990

9091
it('should paginate if nextToken is defined', async () => {
9192
const EXPECTED_CALLS = 3
@@ -104,7 +105,11 @@ describe('ListAllAvailableProfiles Handler', () => {
104105
endpoints: SOME_AWS_Q_ENDPOINT,
105106
})
106107

107-
assert.strictEqual(codeWhispererService.listAvailableProfiles.callCount, EXPECTED_CALLS)
108+
sinon.assert.calledThrice(codeWhispererService.listAvailableProfiles)
109+
assert.strictEqual(codeWhispererService.listAvailableProfiles.firstCall.args[0].nextToken, undefined)
110+
assert.strictEqual(codeWhispererService.listAvailableProfiles.secondCall.args[0].nextToken, SOME_NEXT_TOKEN)
111+
assert.strictEqual(codeWhispererService.listAvailableProfiles.thirdCall.args[0].nextToken, SOME_NEXT_TOKEN)
112+
108113
assert.deepStrictEqual(profiles, Array(EXPECTED_CALLS).fill(EXPECTED_DEVELOPER_PROFILES_LIST[0]))
109114
})
110115

@@ -118,6 +123,13 @@ describe('ListAllAvailableProfiles Handler', () => {
118123
})
119124

120125
assert.strictEqual(codeWhispererService.listAvailableProfiles.callCount, MAX_EXPECTED_PAGES)
126+
codeWhispererService.listAvailableProfiles.getCalls().forEach((call, index) => {
127+
if (index === 0) {
128+
assert.strictEqual(call.args[0].nextToken, undefined)
129+
} else {
130+
assert.strictEqual(call.args[0].nextToken, SOME_NEXT_TOKEN)
131+
}
132+
})
121133
assert.deepStrictEqual(profiles, Array(MAX_EXPECTED_PAGES).fill(EXPECTED_DEVELOPER_PROFILES_LIST[0]))
122134
})
123135
})

0 commit comments

Comments
 (0)