@@ -156,7 +156,7 @@ describe('v2.LoggingServiceV2Client', () => {
156156 } ) ;
157157
158158 if (
159- typeof process !== 'undefined ' &&
159+ typeof process === 'object ' &&
160160 typeof process . emitWarning === 'function'
161161 ) {
162162 it ( 'throws DeprecationWarning if static servicePath is used' , ( ) => {
@@ -192,6 +192,38 @@ describe('v2.LoggingServiceV2Client', () => {
192192 const servicePath = client . apiEndpoint ;
193193 assert . strictEqual ( servicePath , 'logging.example.com' ) ;
194194 } ) ;
195+
196+ if ( typeof process === 'object' && 'env' in process ) {
197+ describe ( 'GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable' , ( ) => {
198+ it ( 'sets apiEndpoint from environment variable' , ( ) => {
199+ const saved = process . env [ 'GOOGLE_CLOUD_UNIVERSE_DOMAIN' ] ;
200+ process . env [ 'GOOGLE_CLOUD_UNIVERSE_DOMAIN' ] = 'example.com' ;
201+ const client = new loggingservicev2Module . v2 . LoggingServiceV2Client ( ) ;
202+ const servicePath = client . apiEndpoint ;
203+ assert . strictEqual ( servicePath , 'logging.example.com' ) ;
204+ if ( saved ) {
205+ process . env [ 'GOOGLE_CLOUD_UNIVERSE_DOMAIN' ] = saved ;
206+ } else {
207+ delete process . env [ 'GOOGLE_CLOUD_UNIVERSE_DOMAIN' ] ;
208+ }
209+ } ) ;
210+
211+ it ( 'value configured in code has priority over environment variable' , ( ) => {
212+ const saved = process . env [ 'GOOGLE_CLOUD_UNIVERSE_DOMAIN' ] ;
213+ process . env [ 'GOOGLE_CLOUD_UNIVERSE_DOMAIN' ] = 'example.com' ;
214+ const client = new loggingservicev2Module . v2 . LoggingServiceV2Client ( {
215+ universeDomain : 'configured.example.com' ,
216+ } ) ;
217+ const servicePath = client . apiEndpoint ;
218+ assert . strictEqual ( servicePath , 'logging.configured.example.com' ) ;
219+ if ( saved ) {
220+ process . env [ 'GOOGLE_CLOUD_UNIVERSE_DOMAIN' ] = saved ;
221+ } else {
222+ delete process . env [ 'GOOGLE_CLOUD_UNIVERSE_DOMAIN' ] ;
223+ }
224+ } ) ;
225+ } ) ;
226+ }
195227 it ( 'does not allow setting both universeDomain and universe_domain' , ( ) => {
196228 assert . throws ( ( ) => {
197229 new loggingservicev2Module . v2 . LoggingServiceV2Client ( {
0 commit comments