Skip to content

Commit bdcd6e2

Browse files
Added a test for the userAgentString
1 parent 199f475 commit bdcd6e2

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
@@ -185,3 +185,12 @@ test.serial('ua.start called on first connect', t => {
185185

186186
t.true(ua.start.called);
187187
});
188+
189+
test.serial('userAgentString is correct', t => {
190+
sinon.stub(Features, 'checkRequired').returns(true);
191+
const userAgentString = 'Test UserAgent string';
192+
const client = createClientImpl(defaultUAFactory(), defaultTransportFactory(), {
193+
userAgentString
194+
});
195+
t.is((client as any).transport.uaOptions.userAgentString, userAgentString);
196+
});

0 commit comments

Comments
 (0)