@@ -96,11 +96,11 @@ describe('visual_recognition', function() {
9696
9797 describe ( 'credentials' , function ( ) {
9898 let env ;
99- before ( function ( ) {
99+ beforeEach ( function ( ) {
100100 env = process . env ;
101101 process . env = { } ;
102102 } ) ;
103- after ( function ( ) {
103+ afterEach ( function ( ) {
104104 process . env = env ;
105105 } ) ;
106106
@@ -148,10 +148,8 @@ describe('visual_recognition', function() {
148148 } ) ;
149149
150150 it ( 'should read VISUAL_RECOGNITION_USERNAME / PASSWORD from environment properties' , function ( ) {
151- process . env = {
152- VISUAL_RECOGNITION_USERNAME : 'foo' ,
153- VISUAL_RECOGNITION_PASSWORD : 'bar' ,
154- } ;
151+ process . env . VISUAL_RECOGNITION_USERNAME = 'foo' ;
152+ process . env . VISUAL_RECOGNITION_PASSWORD = 'bar' ;
155153 const instance = new watson . VisualRecognitionV3 ( {
156154 version : '2016-05-20' ,
157155 } ) ;
@@ -161,48 +159,45 @@ describe('visual_recognition', function() {
161159 } ) ;
162160
163161 it ( 'should read api_key from cf/bluemix environment properties' , function ( ) {
164- process . env = {
165- VCAP_SERVICES : JSON . stringify ( {
166- watson_vision_combined : [
167- {
168- name : 'Visual Recognition-mj' ,
169- label : 'watson_vision_combined' ,
170- plan : 'free' ,
171- credentials : {
172- url : 'https://gateway-a.watsonplatform.net/visual-recognition/api' ,
173- note : 'It may take up to 5 minutes for this key to become active' ,
174- api_key : 'foo' ,
175- } ,
162+ process . env . VCAP_SERVICES = JSON . stringify ( {
163+ watson_vision_combined : [
164+ {
165+ name : 'Visual Recognition-mj' ,
166+ label : 'watson_vision_combined' ,
167+ plan : 'free' ,
168+ credentials : {
169+ url : 'https://gateway-a.watsonplatform.net/visual-recognition/api' ,
170+ note : 'It may take up to 5 minutes for this key to become active' ,
171+ api_key : 'foo' ,
176172 } ,
177- ] ,
178- } ) ,
179- } ;
173+ } ,
174+ ] ,
175+ } ) ;
180176 const instance = new watson . VisualRecognitionV3 ( {
181177 version : '2016-05-20' ,
182178 } ) ;
179+ console . log ( instance . _options ) ;
183180 assert . equal ( instance . _options . api_key , 'foo' ) ;
184181 assert . equal ( instance . _options . username , undefined ) ;
185182 assert . equal ( instance . _options . password , undefined ) ;
186183 } ) ;
187184
188185 it ( 'should read username / password from cf/bluemix environment properties' , function ( ) {
189- process . env = {
190- VCAP_SERVICES : JSON . stringify ( {
191- watson_vision_combined : [
192- {
193- name : 'Visual Recognition-mj' ,
194- label : 'watson_vision_combined' ,
195- plan : 'free' ,
196- credentials : {
197- url : 'https://gateway-a.watsonplatform.net/visual-recognition/api' ,
198- note : 'It may take up to 5 minutes for this key to become active' ,
199- username : 'foo' ,
200- password : 'bar' ,
201- } ,
186+ process . env . VCAP_SERVICES = JSON . stringify ( {
187+ watson_vision_combined : [
188+ {
189+ name : 'Visual Recognition-mj' ,
190+ label : 'watson_vision_combined' ,
191+ plan : 'free' ,
192+ credentials : {
193+ url : 'https://gateway-a.watsonplatform.net/visual-recognition/api' ,
194+ note : 'It may take up to 5 minutes for this key to become active' ,
195+ username : 'foo' ,
196+ password : 'bar' ,
202197 } ,
203- ] ,
204- } ) ,
205- } ;
198+ } ,
199+ ] ,
200+ } ) ;
206201 const instance = new watson . VisualRecognitionV3 ( {
207202 version : '2016-05-20' ,
208203 } ) ;
@@ -524,6 +519,14 @@ describe('visual_recognition', function() {
524519 } ) ;
525520
526521 describe ( 'RC and CF urls' , function ( ) {
522+ let env ;
523+ beforeEach ( function ( ) {
524+ env = process . env ;
525+ process . env = { } ;
526+ } ) ;
527+ afterEach ( function ( ) {
528+ process . env = env ;
529+ } ) ;
527530 it ( 'should have the correct URL depending on rc/cf' , function ( done ) {
528531 const visual_recognition_cf = new watson . VisualRecognitionV3 ( {
529532 api_key : 'apikey' ,
0 commit comments