diff --git a/packages/client/src/client.spec.js b/packages/client/src/client.spec.js index 0b78d649..25ab7a34 100644 --- a/packages/client/src/client.spec.js +++ b/packages/client/src/client.spec.js @@ -3094,19 +3094,25 @@ describe('test_whitelabel_links__link_id__subuser_post', () => { }); -describe('test client', () => { +describe('setDataResidency', () => { const testClient = require('./client'); - describe('setDataResidency', () => { + let consoleWarnSpy; + it('should send to host EU', () => { testClient.setDataResidency('eu'); - console.log('before: '); - console.log(testClient); - console.log('Actual:', testClient.defaultRequest.baseUrl); - it('should have hostname as global', () => { - testClient.setDataResidency('eu'); - console.log('after: '); - console.log(testClient); - expect(testClient.defaultRequest.baseUrl).to.equal('api.eu.sendgrid.com'); - }); + expect(testClient.defaultRequest.baseUrl).to.equal('api.eu.sendgrid.com'); + }); + it('should send to host Global/default', () => { + testClient.setDataResidency('global'); + expect(testClient.defaultRequest.baseUrl).to.equal('api.sendgrid.com'); + }); + it('should give precedence to data residency setter, if called', () => { + testClient.setApiKey('SG.1234567890'); + testClient.setDataResidency('eu'); + expect(testClient.defaultRequest.baseUrl).to.equal('api.eu.sendgrid.com'); + }); + it('should give a warning if the value is not allowed', () => { + testClient.setDataResidency(''); + expect(consoleWarnSpy.calledOnce).to.equal(true); }); });