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 11c2a5c commit 15d99c2
Showing 1 changed file with 9 additions and 51 deletions.
60 changes: 9 additions & 51 deletions packages/client/src/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ const testRequest = (request, statusCode) => {
});
};

const testRequestWithClient = (request, statusCode) => {
const testClient = require('./client');
testClient.setDefaultHeader('X-Mock', statusCode);
testClient.setDataResidency('eu');
return testClient
.request(request)
.then(([response, body]) => {
expect(response.statusCode).to.equal(statusCode);
});
};

describe('client', () => {
const sgClient = require('./client');
let consoleWarnSpy;
Expand Down Expand Up @@ -3108,46 +3097,15 @@ describe('test_whitelabel_links__link_id__subuser_post', () => {

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', () => {
// console.log(testClient);
// expect(testClient.defaultRequest.baseUrl).to.equal('api.eu.sendgrid.com');
// });
// });
it('should test', () => {
const request = {
body: {
content: [
{
type: 'text/plain',
value: '#'.repeat(1024 * 1024 * 10), // 10 MB,
},
],
from: {
email: 'me@you.com',
},
subject: 'Hello, World!',
},
method: 'POST',
url: '/v3/mail/send',
};

return testRequestWithClient(request, 202);
});
it('should send requests to the hostname', () => {
const scope = nock('https://api.eu.sendgrid.com')
.matchHeader('Authorization', /^Bearer SG\.1234567890$/)
.get('/')
.reply(200, 'test response');

sgClient.setDataResidency('eu');

return sgClient.request({})
.then(() => scope.done());
describe('setDataResidency', () => {
testClient.setDataResidency('eu');
console.log('before: ');
console.log(testClient);
console.log('Actual:', testClient.defaultRequest.baseUrl);
it('should have hostname as global', () => {
console.log(testClient);
expect(testClient.defaultRequest.baseUrl).to.equal('api.eu.sendgrid.com');
});
});
});

0 comments on commit 15d99c2

Please sign in to comment.