Skip to content

Commit de94594

Browse files
committed
Add lambda URI handler tests
1 parent 7710b45 commit de94594

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

packages/core/src/lambda/uriHandlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export function registerLambdaUriHandler() {
3131
globals.uriHandler.onPath('/lambda/load-function', openFunctionHandler, parseOpenParams)
3232
)
3333
}
34-
function parseOpenParams(query: SearchParams) {
34+
35+
export function parseOpenParams(query: SearchParams) {
3536
return {
3637
functionName: query.getOrThrow(
3738
'functionName',
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import assert from 'assert'
7+
import { SearchParams } from '../../shared/vscode/uriHandler'
8+
import { parseOpenParams } from '../../lambda/uriHandlers'
9+
import { globals } from '../../shared'
10+
11+
describe('Lambda URI Handler', function () {
12+
describe('load-function', function () {
13+
it('registers for "/lambda/load-function"', function () {
14+
assert.throws(() => globals.uriHandler.onPath('/lambda/load-function', () => {}))
15+
})
16+
17+
it('parses parameters', function () {
18+
let query = new SearchParams({
19+
functionName: 'example',
20+
})
21+
assert.throws(() => parseOpenParams(query), /A region must be provided/)
22+
query = new SearchParams({
23+
region: 'example',
24+
})
25+
assert.throws(() => parseOpenParams(query), /A function name must be provided/)
26+
27+
const valid = {
28+
functionName: 'example',
29+
region: 'example',
30+
isCfn: 'false',
31+
}
32+
query = new SearchParams(valid)
33+
assert.deepEqual(parseOpenParams(query), valid)
34+
})
35+
})
36+
})

0 commit comments

Comments
 (0)