Skip to content

Commit fa0c44f

Browse files
committed
Add tests
1 parent 5447f40 commit fa0c44f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/amplitude-client.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4116,4 +4116,37 @@ describe('AmplitudeClient', function () {
41164116
assert.equal(amplitude.options.apiEndpoint, constants.EVENT_LOG_EU_URL);
41174117
});
41184118
});
4119+
4120+
describe('custom library options', function () {
4121+
beforeEach(function () {
4122+
reset();
4123+
});
4124+
it('should use default library options', function () {
4125+
amplitude.init(apiKey);
4126+
amplitude.logEvent('Event Type 1');
4127+
const { name, version } = JSON.parse(queryString.parse(server.requests[0].requestBody).e)[0].library;
4128+
assert.equal(name, amplitude.options.library.name);
4129+
assert.equal(version, amplitude.options.library.version);
4130+
});
4131+
4132+
it('should change library when passed in options', function () {
4133+
const customLibrary = { name: 'test-library', version: '1.0-test' };
4134+
amplitude.init(apiKey, null, { library: customLibrary });
4135+
amplitude.logEvent('Event Type 1');
4136+
const { name, version } = JSON.parse(queryString.parse(server.requests[0].requestBody).e)[0].library;
4137+
assert.equal(name, 'test-library');
4138+
assert.equal(version, '1.0-test');
4139+
});
4140+
4141+
it('should change library when set with method', function () {
4142+
amplitude.init(apiKey);
4143+
amplitude.setLibrary('test-library', '1.0-test');
4144+
amplitude.logEvent('Event Type 2');
4145+
4146+
const { name, version } = JSON.parse(queryString.parse(server.requests[0].requestBody).e)[0].library;
4147+
4148+
assert.equal(name, 'test-library');
4149+
assert.equal(version, '1.0-test');
4150+
});
4151+
});
41194152
});

0 commit comments

Comments
 (0)