Skip to content

Commit 2858184

Browse files
Added a test for the userAgentString
1 parent 4cafd5d commit 2858184

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

test/_helpers.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ export function defaultTransportFactory() {
2222

2323
export function createClientImpl(
2424
uaFactory: UAFactory,
25-
transportFactory: TransportFactory
25+
transportFactory: TransportFactory,
26+
additionalOptions: UserAgentOptions = {}
2627
): ClientImpl {
27-
return new ClientImpl(uaFactory, transportFactory, minimalOptions());
28+
return new ClientImpl(
29+
uaFactory,
30+
transportFactory,
31+
Object.assign(minimalOptions(), additionalOptions)
32+
);
2833
}
2934

3035
export function createClient() {

test/client-connect.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,12 @@ test.serial('ua.start called on first connect', t => {
218218

219219
t.true(ua.start.called);
220220
});
221+
222+
test.serial('userAgentString is correct', t => {
223+
sinon.stub(Features, 'checkRequired').returns(true);
224+
const userAgentString = 'Test UserAgent string';
225+
const client = createClientImpl(defaultUAFactory(), defaultTransportFactory(), {
226+
userAgentString
227+
});
228+
t.is((client as any).transport.uaOptions.userAgentString, userAgentString);
229+
});

0 commit comments

Comments
 (0)