Skip to content

Commit

Permalink
Update client.spec.js
Browse files Browse the repository at this point in the history
  • Loading branch information
shrutiburman committed Nov 20, 2023
1 parent 7319f84 commit 46b0d40
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions packages/client/src/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 46b0d40

Please sign in to comment.