|
5 | 5 |
|
6 | 6 | import * as assert from 'assert'
|
7 | 7 | import { Lambda } from 'aws-sdk'
|
8 |
| -import * as os from 'os' |
9 |
| -import { LambdaFunctionNode, LambdaNode } from '../../../lambda/explorer/lambdaNodes' |
| 8 | +import { LambdaFunctionNode } from '../../../lambda/explorer/lambdaFunctionNode' |
| 9 | +import { CONTEXT_VALUE_LAMBDA_FUNCTION, LambdaNode } from '../../../lambda/explorer/lambdaNodes' |
10 | 10 | import { CloudFormationClient } from '../../../shared/clients/cloudFormationClient'
|
11 | 11 | import { EcsClient } from '../../../shared/clients/ecsClient'
|
12 | 12 | import { LambdaClient } from '../../../shared/clients/lambdaClient'
|
13 | 13 | import { StsClient } from '../../../shared/clients/stsClient'
|
14 | 14 | import { ext } from '../../../shared/extensionGlobals'
|
15 | 15 | import { ErrorNode } from '../../../shared/treeview/nodes/errorNode'
|
16 | 16 | import { MockLambdaClient } from '../../shared/clients/mockClients'
|
17 |
| -import { TestAWSTreeNode } from '../../shared/treeview/nodes/testAWSTreeNode' |
18 |
| -import { clearTestIconPaths, IconPath, setupTestIconPaths } from '../../shared/utilities/iconPathUtils' |
19 | 17 |
|
20 | 18 | // TODO : Consolidate all asyncGenerator calls into a shared utility method
|
21 | 19 | async function* asyncGenerator<T>(items: T[]): AsyncIterableIterator<T> {
|
22 | 20 | yield* items
|
23 | 21 | }
|
24 | 22 |
|
25 |
| -describe('LambdaFunctionNode', () => { |
26 |
| - let fakeFunctionConfig: Lambda.FunctionConfiguration |
27 |
| - |
28 |
| - before(async () => { |
29 |
| - setupTestIconPaths() |
30 |
| - fakeFunctionConfig = { |
31 |
| - FunctionName: 'testFunctionName', |
32 |
| - FunctionArn: 'testFunctionARN' |
33 |
| - } |
34 |
| - }) |
35 |
| - |
36 |
| - after(async () => { |
37 |
| - clearTestIconPaths() |
38 |
| - }) |
39 |
| - |
40 |
| - // Validates we tagged the node correctly |
41 |
| - it('initializes name and tooltip', async () => { |
42 |
| - const testNode = generateTestNode() |
43 |
| - |
44 |
| - assert.strictEqual(testNode.label, fakeFunctionConfig.FunctionName) |
45 |
| - assert.strictEqual( |
46 |
| - testNode.tooltip, |
47 |
| - `${fakeFunctionConfig.FunctionName}${os.EOL}${fakeFunctionConfig.FunctionArn}` |
48 |
| - ) |
49 |
| - }) |
50 |
| - |
51 |
| - it('initializes icon', async () => { |
52 |
| - const testNode = generateTestNode() |
53 |
| - |
54 |
| - const iconPath = testNode.iconPath as IconPath |
55 |
| - |
56 |
| - assert.strictEqual(iconPath.dark.path, ext.iconPaths.dark.lambda, 'Unexpected dark icon path') |
57 |
| - assert.strictEqual(iconPath.light.path, ext.iconPaths.light.lambda, 'Unexpected light icon path') |
58 |
| - }) |
59 |
| - |
60 |
| - // Validates we don't yield some unexpected value that our command triggers |
61 |
| - // don't recognize |
62 |
| - it('returns expected context value', async () => { |
63 |
| - const testNode = generateTestNode() |
64 |
| - |
65 |
| - assert.strictEqual(testNode.contextValue, 'awsRegionFunctionNode') |
66 |
| - }) |
67 |
| - |
68 |
| - // Validates function nodes are leaves |
69 |
| - it('has no children', async () => { |
70 |
| - const testNode = generateTestNode() |
71 |
| - |
72 |
| - const childNodes = await testNode.getChildren() |
73 |
| - assert(childNodes !== undefined) |
74 |
| - assert.strictEqual(childNodes.length, 0) |
75 |
| - }) |
76 |
| - |
77 |
| - function generateTestNode(): LambdaFunctionNode { |
78 |
| - const parentNode = new TestAWSTreeNode('test node') |
79 |
| - |
80 |
| - return new LambdaFunctionNode(parentNode, 'someregioncode', fakeFunctionConfig) |
81 |
| - } |
82 |
| -}) |
83 |
| - |
84 | 23 | describe('LambdaNode', () => {
|
85 | 24 | class FunctionNamesMockLambdaClient extends MockLambdaClient {
|
86 | 25 | public constructor(
|
@@ -147,6 +86,12 @@ describe('LambdaNode', () => {
|
147 | 86 | actualChildNode: LambdaFunctionNode | ErrorNode,
|
148 | 87 | expectedNodeText: string
|
149 | 88 | ) {
|
| 89 | + assert.strictEqual( |
| 90 | + actualChildNode.contextValue, |
| 91 | + CONTEXT_VALUE_LAMBDA_FUNCTION, |
| 92 | + 'Expected child node to be marked as a Lambda Function' |
| 93 | + ) |
| 94 | + |
150 | 95 | assert.strictEqual(
|
151 | 96 | 'functionName' in actualChildNode,
|
152 | 97 | true,
|
|
0 commit comments