@@ -1742,12 +1742,27 @@ describe('#compileStateMachines', () => {
1742
1742
States : {
1743
1743
'Store inputs' : {
1744
1744
Type : 'Pass' ,
1745
- Next : 'Output transformation ' ,
1745
+ Next : 'Get Current Price ' ,
1746
1746
Assign : {
1747
1747
desiredPrice : '{% $states.input.desired_price %}' ,
1748
1748
maximumWait : '{% $states.input.max_days %}' ,
1749
1749
} ,
1750
1750
} ,
1751
+ 'Get Current Price' : {
1752
+ Type : 'Task' ,
1753
+ QueryLanguage : 'JSONata' ,
1754
+ Resource : 'arn:aws:states:::lambda:invoke' ,
1755
+ Next : 'Output transformation' ,
1756
+ Arguments : {
1757
+ Payload : {
1758
+ product : '{% $states.context.Execution.Input.product %}' ,
1759
+ } ,
1760
+ FunctionName : 'arn:aws:lambda:<region>:123456789012:function:priceWatcher:$LATEST' ,
1761
+ } ,
1762
+ Assign : {
1763
+ currentPrice : '{% $states.result.Payload.current_price %}' ,
1764
+ } ,
1765
+ } ,
1751
1766
'Output transformation' : {
1752
1767
Type : 'Succeed' ,
1753
1768
Output : {
@@ -1771,13 +1786,23 @@ describe('#compileStateMachines', () => {
1771
1786
expect ( stateMachine . Properties . DefinitionString ) . not . to . haveOwnProperty ( 'Fn::Sub' ) ;
1772
1787
const stateMachineObj = JSON . parse ( stateMachine . Properties . DefinitionString ) ;
1773
1788
expect ( stateMachineObj . States ) . to . haveOwnProperty ( 'Store inputs' ) ;
1789
+ expect ( stateMachineObj . States ) . to . haveOwnProperty ( 'Get Current Price' ) ;
1774
1790
expect ( stateMachineObj . States ) . to . haveOwnProperty ( 'Output transformation' ) ;
1775
1791
1776
1792
expect ( stateMachineObj . QueryLanguage ) . to . equal ( 'JSONata' ) ;
1777
1793
expect ( stateMachineObj . States [ 'Store inputs' ] . Assign ) . to . deep . equal ( {
1778
1794
desiredPrice : '{% $states.input.desired_price %}' ,
1779
1795
maximumWait : '{% $states.input.max_days %}' ,
1780
1796
} ) ;
1797
+ expect ( stateMachineObj . States [ 'Get Current Price' ] . Arguments ) . to . deep . equal ( {
1798
+ Payload : {
1799
+ product : '{% $states.context.Execution.Input.product %}' ,
1800
+ } ,
1801
+ FunctionName : 'arn:aws:lambda:<region>:123456789012:function:priceWatcher:$LATEST' ,
1802
+ } ) ;
1803
+ expect ( stateMachineObj . States [ 'Get Current Price' ] . Assign ) . to . deep . equal ( {
1804
+ currentPrice : '{% $states.result.Payload.current_price %}' ,
1805
+ } ) ;
1781
1806
expect ( stateMachineObj . States [ 'Output transformation' ] . Output ) . to . deep . equal ( {
1782
1807
lastName : "{% 'Last=>' & $states.input.customer.lastName %}" ,
1783
1808
orderValue : '{% $states.input.order.total %}' ,
0 commit comments