@@ -18,16 +18,6 @@ describe('RemoteInvokeWebview', function () {
1818 const mockData = {
1919 FunctionArn : 'arn:aws:lambda:us-west-2:123456789012:function:my-function' ,
2020 } as any
21- const mockDataLMI = {
22- FunctionArn : 'arn:aws:lambda:us-west-2:123456789012:function:my-function' ,
23- LambdaFunctionNode : {
24- configuration : {
25- CapacityProviderConfig : {
26- blah : 'blah' ,
27- } ,
28- } ,
29- } ,
30- } as any
3121 const input = '{"key": "value"}'
3222 const mockResponse = {
3323 LogResult : Buffer . from ( 'Test log' ) . toString ( 'base64' ) ,
@@ -46,21 +36,83 @@ describe('RemoteInvokeWebview', function () {
4636 afterEach ( ( ) => {
4737 sinon . restore ( )
4838 } )
49- it ( 'should invoke with a simple payload' , async function ( ) {
50- const remoteInvokeWebview = new RemoteInvokeWebview ( outputChannel , client , client , mockData )
51- client . invoke . resolves ( mockResponse )
52- await remoteInvokeWebview . invokeLambda ( input )
53- sinon . assert . calledOnce ( client . invoke )
54- sinon . assert . calledWith ( client . invoke , mockData . FunctionArn , input , undefined , 'Tail' )
55- } )
39+ const invokeScenarios : {
40+ name : string
41+ data : any
42+ expectedQualifier : string | undefined
43+ expectedLogType : 'Tail' | 'None'
44+ } [ ] = [
45+ {
46+ name : 'should invoke with a simple payload' ,
47+ data : mockData ,
48+ expectedQualifier : undefined ,
49+ expectedLogType : 'Tail' ,
50+ } ,
51+ {
52+ name : 'should invoke with no tail in LMI' ,
53+ data : {
54+ FunctionArn : 'arn:aws:lambda:us-west-2:123456789012:function:my-function' ,
55+ LambdaFunctionNode : {
56+ configuration : {
57+ CapacityProviderConfig : {
58+ blah : 'blah' ,
59+ } ,
60+ } ,
61+ } ,
62+ } ,
63+ expectedQualifier : undefined ,
64+ expectedLogType : 'None' ,
65+ } ,
66+ {
67+ name : 'should invoke $LATEST in Durable Function' ,
68+ data : {
69+ FunctionArn : 'arn:aws:lambda:us-west-2:123456789012:function:my-function' ,
70+ LambdaFunctionNode : {
71+ configuration : {
72+ DurableConfig : {
73+ blah : 'blah' ,
74+ } ,
75+ } ,
76+ } ,
77+ } ,
78+ expectedQualifier : '$LATEST' ,
79+ expectedLogType : 'Tail' ,
80+ } ,
81+ {
82+ name : 'should invoke $LATEST.PUBLISHED in LMI Durable Function' ,
83+ data : {
84+ FunctionArn : 'arn:aws:lambda:us-west-2:123456789012:function:my-function' ,
85+ LambdaFunctionNode : {
86+ configuration : {
87+ DurableConfig : {
88+ blah : 'blah' ,
89+ } ,
90+ CapacityProviderConfig : {
91+ blah : 'blah' ,
92+ } ,
93+ } ,
94+ } ,
95+ } ,
96+ expectedQualifier : '$LATEST.PUBLISHED' ,
97+ expectedLogType : 'None' ,
98+ } ,
99+ ]
56100
57- it ( 'should invoke with no tail in LMI' , async function ( ) {
58- const remoteInvokeWebview = new RemoteInvokeWebview ( outputChannel , client , client , mockDataLMI )
59- client . invoke . resolves ( mockResponse )
60- await remoteInvokeWebview . invokeLambda ( input )
61- sinon . assert . calledOnce ( client . invoke )
62- sinon . assert . calledWith ( client . invoke , mockData . FunctionArn , input , undefined , 'None' )
63- } )
101+ for ( const scenario of invokeScenarios ) {
102+ it ( scenario . name , async function ( ) {
103+ const remoteInvokeWebview = new RemoteInvokeWebview ( outputChannel , client , client , scenario . data )
104+ client . invoke . resolves ( mockResponse )
105+ await remoteInvokeWebview . invokeLambda ( input )
106+ sinon . assert . calledOnce ( client . invoke )
107+ sinon . assert . calledWith (
108+ client . invoke ,
109+ scenario . data . FunctionArn ,
110+ input ,
111+ scenario . expectedQualifier ,
112+ scenario . expectedLogType
113+ )
114+ } )
115+ }
64116
65117 const mockEvent = {
66118 name : 'TestEvent' ,
0 commit comments