From 46b0d40b242ad484fd1a9b6dde28c47d387f9b72 Mon Sep 17 00:00:00 2001 From: sburman Date: Mon, 20 Nov 2023 13:29:07 +0530 Subject: [PATCH] Update client.spec.js --- packages/client/src/client.spec.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) 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); }); });