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 91b4cb6 commit 7319f84
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
node: [ '6', '7', '8', '10', '12', '14', '16', 'lts' ]
node: [10, 14, 16, lts]
env:
version: ${{ matrix.node }}
DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"moment": "^2.19.3",
"sinon": "^2.3.2",
"sinon-chai": "^2.10.0",
"typescript": "^3.7.4"
"typescript": "^4.0.0"
},
"scripts": {
"lint": "if [ `node --version | cut -d'.' -f1 | cut -c 2` -ge \"8\" ]; then eslint . --fix; else echo \"eslint is not available for node < 8.0\"; fi",
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/classes/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class Client {
} else {
this.setDefaultRequest('baseUrl', REGION_HOST_MAP[region]);
}
return this;
}

createHeaders(data) {
Expand Down
5 changes: 5 additions & 0 deletions packages/client/src/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ declare class Client {
*/
setDefaultRequest<K extends keyof ClientRequest>(key: K | ClientRequest, value ?: ClientRequest[K]): this;

/**
* Sets the data residency as per region provided
*/
setDataResidency(region: string): this;

/**
* Create headers for request
*/
Expand Down
21 changes: 15 additions & 6 deletions packages/client/src/client.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const nock = require('nock');
const sgClient = require('./client');

const testClient = require('./client');
const testRequest = (request, statusCode) => {
const sgClient = require('./client');
sgClient.setApiKey('SG.API Key');
Expand Down Expand Up @@ -3093,11 +3093,20 @@ describe('test_whitelabel_links__link_id__subuser_post', () => {
});
});

describe('setDataResidency', () => {
const sgClient = require('./client');
sgClient.setDataResidency('eu');

it('should have host as eu', () => {
expect(sgClient.baseUrl).to.equal('api.eu.sendgrid.com');
describe('test client', () => {
const testClient = require('./client');
describe('setDataResidency', () => {
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');
});
});
});

0 comments on commit 7319f84

Please sign in to comment.