Skip to content

Commit

Permalink
allow using custom client config in checkConnection() method (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevez authored Jun 17, 2024
1 parent 0846655 commit 679c72c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/report-portal-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class RPClient {

checkConnect() {
const url = [this.config.endpoint.replace('/v2', '/v1'), 'user'].join('/');
return RestClient.request('GET', url, {}, { headers: this.headers });
return RestClient.request('GET', url, {}, { headers: this.headers, ...this.restClient.getRestConfig()});
}

async triggerStatisticsEvent() {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions spec/report-portal-client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,30 @@ describe('ReportPortal javascript client', () => {

return expectAsync(request).toBeResolved();
});

it('client should include restClientConfig', () => {
const client = new RPClient({
apiKey: 'test',
project: 'test',
endpoint: 'https://abc.com/v1',
restClientConfig: {
proxy: false,
timeout: 0,
}
});
spyOn(RestClient, 'request');

client.checkConnect();

expect(RestClient.request).toHaveBeenCalledWith('GET','https://abc.com/v1/user', {}, {
headers: {
'User-Agent': 'NodeJS',
Authorization: `bearer test`,
},
proxy: false,
timeout: 0,
});
});
});

describe('triggerAnalyticsEvent', () => {
Expand Down

0 comments on commit 679c72c

Please sign in to comment.