Skip to content

Commit 88ab839

Browse files
oscargrpabisalehalliprasan
authored andcommitted
Add more code coverage for OAuthClient (#54)
* Add better code coverage in OAuthClient
1 parent 73aa0dd commit 88ab839

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/OAuthClientTest.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ describe('Tests for OAuthClient', () => {
262262
});
263263

264264
// make API Call
265-
describe('Make API Call ', () => {
265+
describe('Make API Call', () => {
266266
before(() => {
267267
nock('https://sandbox-quickbooks.api.intuit.com').persist()
268268
.get('/v3/company/12345/companyinfo/12345')
@@ -285,6 +285,20 @@ describe('Tests for OAuthClient', () => {
285285
.to.be.equal(JSON.stringify(expectedMakeAPICall));
286286
});
287287
});
288+
it('Make API Call in Sandbox Environment with headers as parameters', () => {
289+
oauthClient.getToken().realmId = '12345';
290+
// eslint-disable-next-line no-useless-concat
291+
return oauthClient.makeApiCall({
292+
url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/' + '12345' + '/companyinfo/' + '12345',
293+
headers: {
294+
Accept: "application/json",
295+
}
296+
})
297+
.then((authResponse) => {
298+
expect(JSON.stringify(authResponse.getJson()))
299+
.to.be.equal(JSON.stringify(expectedMakeAPICall));
300+
});
301+
});
288302
it('loadResponseFromJWKsURI', () => {
289303
const request = {
290304
url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/12345/companyinfo/12345',
@@ -474,6 +488,10 @@ describe('Generate OAuth1Sign', () => {
474488

475489
const oauth1Sign = oauthClient.generateOauth1Sign(params);
476490
expect(oauth1Sign).to.be.a('String');
491+
expect(oauth1Sign).to.have.string('oauth_consumer_key="qyprdFsHNQtdRupMKmYnDt6MOjWBW9');
492+
expect(oauth1Sign).to.have.string('oauth_nonce="nonce');
493+
expect(oauth1Sign).to.have.string('oauth_version="1.0');
494+
expect(oauth1Sign).to.have.string('oauth_token', 'oauth_timestamp', 'oauth_signature');
477495
});
478496
});
479497

0 commit comments

Comments
 (0)