Skip to content

Commit

Permalink
Added a test for the userAgentString
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickswijgman committed Mar 2, 2020
1 parent 4cafd5d commit 2858184
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ export function defaultTransportFactory() {

export function createClientImpl(
uaFactory: UAFactory,
transportFactory: TransportFactory
transportFactory: TransportFactory,
additionalOptions: UserAgentOptions = {}
): ClientImpl {
return new ClientImpl(uaFactory, transportFactory, minimalOptions());
return new ClientImpl(
uaFactory,
transportFactory,
Object.assign(minimalOptions(), additionalOptions)
);
}

export function createClient() {
Expand Down
9 changes: 9 additions & 0 deletions test/client-connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,12 @@ test.serial('ua.start called on first connect', t => {

t.true(ua.start.called);
});

test.serial('userAgentString is correct', t => {
sinon.stub(Features, 'checkRequired').returns(true);
const userAgentString = 'Test UserAgent string';
const client = createClientImpl(defaultUAFactory(), defaultTransportFactory(), {
userAgentString
});
t.is((client as any).transport.uaOptions.userAgentString, userAgentString);
});

0 comments on commit 2858184

Please sign in to comment.