Skip to content

Commit

Permalink
fix: persist enableGzipCompression setting on the base service (#127)
Browse files Browse the repository at this point in the history
When a new `BaseService` instance is created, the class settings are stored in an object
called `baseOptions`. Currently, when the `setEnableGzipCompression` method is called,
the `enableGzipCompression` setting is not changed and might no longer reflect the state
of the setting (because it is primarily tracked in the underlying `RequestWrapper` class).

This PR addresses this by persisting the setting in the `baseOptions` object when that method
is called so that the object always reflects the accurate value for the setting.
  • Loading branch information
dpopp07 authored Mar 12, 2021
1 parent bfc59ae commit 1398044
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export class BaseService {
*/
public setEnableGzipCompression(setting: boolean): void {
this.requestWrapperInstance.compressRequestData = setting;

// persist setting so that baseOptions accurately reflects the state of the flag
this.baseOptions.enableGzipCompression = setting;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions test/unit/base-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ describe('Base Service', () => {
const on = true;
testService.setEnableGzipCompression(on);
expect(testService.requestWrapperInstance.compressRequestData).toBe(on);
expect(testService.baseOptions.enableGzipCompression).toBe(on);

const off = false;
testService.setEnableGzipCompression(off);
expect(testService.requestWrapperInstance.compressRequestData).toBe(off);
expect(testService.baseOptions.enableGzipCompression).toBe(off);
});

it('should throw an error if an authenticator is not passed in', () => {
Expand Down

0 comments on commit 1398044

Please sign in to comment.