From bdcd6e220bfa0386855989864114b44a7f0a2265 Mon Sep 17 00:00:00 2001 From: Patrick Swijgman Date: Mon, 17 Feb 2020 13:43:41 +0100 Subject: [PATCH] Added a test for the userAgentString --- test/_helpers.ts | 9 +++++++-- test/client-connect.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/_helpers.ts b/test/_helpers.ts index 371018ac..11e6d405 100644 --- a/test/_helpers.ts +++ b/test/_helpers.ts @@ -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() { diff --git a/test/client-connect.ts b/test/client-connect.ts index e108c78f..1ebde898 100644 --- a/test/client-connect.ts +++ b/test/client-connect.ts @@ -185,3 +185,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); +});