-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11c2a5c
commit 15d99c2
Showing
1 changed file
with
9 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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: '[email protected]', | ||
}, | ||
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'); | ||
}); | ||
}); | ||
}); | ||
|