22
33const  AssistantV1  =  require ( '../../assistant/v1' ) ; 
44const  authHelper  =  require ( '../resources/auth_helper.js' ) ; 
5- const  auth  =  authHelper . auth ; 
65const  describe  =  authHelper . describe ;  // this runs describe.skip if there is no auth.js file :) 
76const  assign  =  require ( 'object.assign' ) ;  // for node v0.12 compatibility 
87const  serviceErrorUtils  =  require ( '../resources/service_error_util' ) ; 
@@ -100,10 +99,16 @@ const test_dialog_node_update = 'updated_node';
10099// changing language is forbidden starting with VERSION_DATE_2017_05_26 
101100const  workspace1  =  extend ( true ,  { } ,  workspace ,  intents ,  {  language : workspace . language  } ) ; 
102101
102+ // extract service params from auth.js 
103+ 
103104describe ( 'assistant_integration' ,  function ( )  { 
104105  jest . setTimeout ( TEN_SECONDS ) ; 
105-   auth . assistant . version  =  '2019-03-27' ; 
106-   const  assistant  =  new  AssistantV1 ( auth . assistant ) ; 
106+   const  auth  =  authHelper . auth . assistant ; 
107+   const  {  workspaceId }  =  auth ; 
108+ 
109+   auth . version  =  '2019-03-27' ; 
110+   auth . iam_apikey  =  auth . apikey ; 
111+   const  assistant  =  new  AssistantV1 ( auth ) ; 
107112
108113  describe ( 'message()' ,  function ( )  { 
109114    it ( 'alternate_intents with custom headers' ,  function ( done )  { 
@@ -112,7 +117,7 @@ describe('assistant_integration', function() {
112117          text : 'Turn on the lights' , 
113118        } , 
114119        alternate_intents : true , 
115-         workspace_id : auth . assistant . workspace_id , 
120+         workspace_id : workspaceId , 
116121        headers : { 
117122          customheader : 'custom' , 
118123        } , 
@@ -133,7 +138,7 @@ describe('assistant_integration', function() {
133138    } ) ; 
134139
135140    it ( 'dialog_stack with 2017-02-03 version' ,  function ( done )  { 
136-       const  constructorParams  =  assign ( { } ,  auth . assistant ,  { 
141+       const  constructorParams  =  assign ( { } ,  auth ,  { 
137142        version : '2017-02-03' , 
138143      } ) ; 
139144      const  assistant  =  new  AssistantV1 ( constructorParams ) ; 
@@ -142,7 +147,7 @@ describe('assistant_integration', function() {
142147        input : { 
143148          text : 'Turn on the lights' , 
144149        } , 
145-         workspace_id : auth . assistant . workspace_id , 
150+         workspace_id : workspaceId , 
146151      } ; 
147152
148153      assistant . message ( 
@@ -160,7 +165,7 @@ describe('assistant_integration', function() {
160165    } ) ; 
161166
162167    it ( 'dialog_stack with 2016-09-20 version' ,  function ( done )  { 
163-       const  constructorParams  =  assign ( { } ,  auth . assistant ,  { 
168+       const  constructorParams  =  assign ( { } ,  auth ,  { 
164169        version : '2016-09-20' , 
165170      } ) ; 
166171      const  assistant  =  new  AssistantV1 ( constructorParams ) ; 
@@ -169,7 +174,7 @@ describe('assistant_integration', function() {
169174        input : { 
170175          text : 'Turn on the lights' , 
171176        } , 
172-         workspace_id : auth . assistant . workspace_id , 
177+         workspace_id : workspaceId , 
173178      } ; 
174179
175180      assistant . message ( 
@@ -187,7 +192,7 @@ describe('assistant_integration', function() {
187192    } ) ; 
188193
189194    it ( 'dialog_stack with 2016-07-11 version' ,  function ( done )  { 
190-       const  constructorParams  =  assign ( { } ,  auth . assistant ,  { 
195+       const  constructorParams  =  assign ( { } ,  auth ,  { 
191196        version : '2016-07-11' , 
192197      } ) ; 
193198      const  assistant  =  new  AssistantV1 ( constructorParams ) ; 
@@ -196,7 +201,7 @@ describe('assistant_integration', function() {
196201        input : { 
197202          text : 'Turn on the lights' , 
198203        } , 
199-         workspace_id : auth . assistant . workspace_id , 
204+         workspace_id : workspaceId , 
200205      } ; 
201206
202207      assistant . message ( 
0 commit comments