@@ -16,7 +16,7 @@ describe('#compileStateMachines', () => {
16
16
serverless . cli = new CLI ( serverless ) ;
17
17
serverless . configSchemaHandler = {
18
18
// eslint-disable-next-line no-unused-vars
19
- defineTopLevelProperty : ( propertyName , propertySchema ) => { } ,
19
+ defineTopLevelProperty : ( propertyName , propertySchema ) => { } ,
20
20
} ;
21
21
serverless . servicePath = true ;
22
22
serverless . service . service = 'step-functions' ;
@@ -1728,4 +1728,59 @@ describe('#compileStateMachines', () => {
1728
1728
const stateMachineObj = JSON . parse ( stateMachine . Properties . DefinitionString ) ;
1729
1729
expect ( stateMachineObj . States ) . to . haveOwnProperty ( 'One' ) ;
1730
1730
} ) ;
1731
+
1732
+ it ( 'should compile with the new JSONata fields' , ( ) => {
1733
+ serverless . service . stepFunctions = {
1734
+ stateMachines : {
1735
+ myStateMachine1 : {
1736
+ id : 'Test' ,
1737
+ name : 'Test' ,
1738
+ definition : {
1739
+ Comment : 'Test JSONata features' ,
1740
+ QueryLanguage : 'JSONata' ,
1741
+ StartAt : 'Store inputs' ,
1742
+ States : {
1743
+ 'Store inputs' : {
1744
+ Type : 'Pass' ,
1745
+ Next : 'Output transformation' ,
1746
+ Assign : {
1747
+ desiredPrice : '{% $states.input.desired_price %}' ,
1748
+ maximumWait : '{% $states.input.max_days %}' ,
1749
+ } ,
1750
+ } ,
1751
+ 'Output transformation' : {
1752
+ Type : 'Succeed' ,
1753
+ Output : {
1754
+ lastName :
1755
+ "{% 'Last=>' & $states.input.customer.lastName %}" ,
1756
+ orderValue : '{% $states.input.order.total %}' ,
1757
+ } ,
1758
+ } ,
1759
+ } ,
1760
+ } ,
1761
+ } ,
1762
+ } ,
1763
+ } ;
1764
+
1765
+ serverlessStepFunctions . compileStateMachines ( ) ;
1766
+
1767
+ const stateMachine = serverlessStepFunctions . serverless . service
1768
+ . provider . compiledCloudFormationTemplate . Resources
1769
+ . Test ;
1770
+
1771
+ expect ( stateMachine . Properties . DefinitionString ) . not . to . haveOwnProperty ( 'Fn::Sub' ) ;
1772
+ const stateMachineObj = JSON . parse ( stateMachine . Properties . DefinitionString ) ;
1773
+ expect ( stateMachineObj . States ) . to . haveOwnProperty ( 'Store inputs' ) ;
1774
+ expect ( stateMachineObj . States ) . to . haveOwnProperty ( 'Output transformation' ) ;
1775
+
1776
+ expect ( stateMachineObj . QueryLanguage ) . to . equal ( 'JSONata' ) ;
1777
+ expect ( stateMachineObj . States [ 'Store inputs' ] . Assign ) . to . deep . equal ( {
1778
+ desiredPrice : '{% $states.input.desired_price %}' ,
1779
+ maximumWait : '{% $states.input.max_days %}' ,
1780
+ } ) ;
1781
+ expect ( stateMachineObj . States [ 'Output transformation' ] . Output ) . to . deep . equal ( {
1782
+ lastName : "{% 'Last=>' & $states.input.customer.lastName %}" ,
1783
+ orderValue : '{% $states.input.order.total %}' ,
1784
+ } ) ;
1785
+ } ) ;
1731
1786
} ) ;
0 commit comments