@@ -14,6 +14,9 @@ const variables = {
1414 'contact.email' :
'[email protected] ' , 1515 'contact.phone' : '1234567890' ,
1616 'conversation.id' : 1 ,
17+ 'conversation.code' : 'CW123' ,
18+ 'inbox.id' : 1 ,
19+ 'inbox.name' : 'Inbox 1' ,
1720 'agent.first_name' : 'Samuel' ,
1821 'agent.last_name' : 'Smith' ,
1922 'agent.email' :
'[email protected] ' , @@ -52,6 +55,13 @@ describe('#replaceVariablesInMessage', () => {
5255 ) ;
5356 } ) ;
5457
58+ it ( 'returns the message with inbox name' , ( ) => {
59+ const message = 'Welcome to {{inbox.name}}' ;
60+ expect ( replaceVariablesInMessage ( { message, variables } ) ) . toBe (
61+ 'Welcome to Inbox 1'
62+ ) ;
63+ } ) ;
64+
5565 it ( 'returns the message if the variable is not present in variables' , ( ) => {
5666 const message = 'Please dm me at {{contact.twitter}}' ;
5767 expect ( replaceVariablesInMessage ( { message, variables } ) ) . toBe (
@@ -102,6 +112,7 @@ describe('#getMessageVariables', () => {
102112 } ,
103113 } ,
104114 id : 1 ,
115+ code : 'CW123' ,
105116 custom_attributes : {
106117 car_model : 'Tesla Model S' ,
107118 car_year : '2022' ,
@@ -117,15 +128,21 @@ describe('#getMessageVariables', () => {
117128 phone_number : '1234567890' ,
118129 custom_attributes : { priority : 'high' } ,
119130 } ;
131+ const inbox = {
132+ id : 1 ,
133+ name : 'Inbox 1' ,
134+ } ;
120135
121- expect ( getMessageVariables ( { conversation, contact } ) ) . toEqual ( {
136+ expect ( getMessageVariables ( { conversation, contact, inbox } ) ) . toEqual ( {
122137 'contact.name' : 'John Doe' ,
123138 'contact.first_name' : 'John' ,
124139 'contact.id' : 3 ,
125140 'contact.last_name' : 'Doe' ,
126141 'contact.email' :
'[email protected] ' , 127142 'contact.phone' : '1234567890' ,
128143 'conversation.id' : 1 ,
144+ 'inbox.id' : 1 ,
145+ 'inbox.name' : 'Inbox 1' ,
129146 'agent.name' : 'Samuel Smith' ,
130147 'agent.first_name' : 'Samuel' ,
131148 'agent.last_name' : 'Smith' ,
0 commit comments