Skip to content

Commit ba195e6

Browse files
author
Daniel Jih
committed
add amplitude client tests
1 parent e53703d commit ba195e6

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

test/amplitude-client.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ describe('AmplitudeClient', function() {
384384
localStorage.setItem('amplitude_unsent', existingEvent);
385385
localStorage.setItem('amplitude_unsent_identify', existingIdentify);
386386

387-
var amplitude2 = new Amplitude();
387+
var amplitude2 = new AmplitudeClient('$default_Instance');
388388
amplitude2.init(apiKey, null, {batchEvents: true});
389389

390390
// check event loaded into memory
@@ -891,7 +891,7 @@ describe('setVersionName', function() {
891891
message = response;
892892
}
893893
var identify = new amplitude.Identify().set('key', 'value');
894-
new Amplitude().identify(identify, callback);
894+
new AmplitudeClient().identify(identify, callback);
895895

896896
// verify callback fired
897897
assert.equal(counter, 1);
@@ -1037,7 +1037,7 @@ describe('setVersionName', function() {
10371037
amplitude.logEvent('Event', {index: 2});
10381038
amplitude.logEvent('Event', {index: 3});
10391039

1040-
var amplitude2 = new Amplitude();
1040+
var amplitude2 = new AmplitudeClient();
10411041
amplitude2.init(apiKey);
10421042
assert.deepEqual(amplitude2._unsentEvents, amplitude._unsentEvents);
10431043
});
@@ -1048,7 +1048,7 @@ describe('setVersionName', function() {
10481048
amplitude.logEvent('Event', {index: 2});
10491049
amplitude.logEvent('Event', {index: 3});
10501050

1051-
var amplitude2 = new Amplitude();
1051+
var amplitude2 = new AmplitudeClient();
10521052
amplitude2.init(apiKey);
10531053
assert.deepEqual(amplitude2._unsentEvents, []);
10541054
});
@@ -1730,7 +1730,7 @@ describe('setVersionName', function() {
17301730
it('should increment the counters in local storage if cookies disabled', function() {
17311731
localStorage.clear();
17321732
var deviceId = 'test_device_id';
1733-
var amplitude2 = new Amplitude();
1733+
var amplitude2 = new AmplitudeClient();
17341734

17351735
sinon.stub(CookieStorage.prototype, '_cookiesEnabled').returns(false);
17361736
amplitude2.init(apiKey, null, {deviceId: deviceId, batchEvents: true, eventUploadThreshold: 5});
@@ -1814,9 +1814,9 @@ describe('setVersionName', function() {
18141814

18151815
it('should synchronize event data across multiple amplitude instances that share the same cookie', function() {
18161816
// this test fails if logEvent does not reload cookie data every time
1817-
var amplitude1 = new Amplitude();
1817+
var amplitude1 = new AmplitudeClient();
18181818
amplitude1.init(apiKey, null, {batchEvents: true, eventUploadThreshold: 5});
1819-
var amplitude2 = new Amplitude();
1819+
var amplitude2 = new AmplitudeClient();
18201820
amplitude2.init(apiKey, null, {batchEvents: true, eventUploadThreshold: 5});
18211821

18221822
amplitude1.logEvent('test1');
@@ -1925,13 +1925,13 @@ describe('setVersionName', function() {
19251925
});
19261926

19271927
it('should have state be persisted in the cookie', function() {
1928-
var amplitude = new Amplitude();
1928+
var amplitude = new AmplitudeClient();
19291929
amplitude.init(apiKey);
19301930
assert.strictEqual(amplitude.options.optOut, false);
19311931

19321932
amplitude.setOptOut(true);
19331933

1934-
var amplitude2 = new Amplitude();
1934+
var amplitude2 = new AmplitudeClient();
19351935
amplitude2.init(apiKey);
19361936
assert.strictEqual(amplitude2.options.optOut, true);
19371937
});
@@ -2356,7 +2356,7 @@ describe('setVersionName', function() {
23562356
it('should be fetched correctly by getSessionId', function() {
23572357
var timestamp = 1000;
23582358
clock.tick(timestamp);
2359-
var amplitude2 = new Amplitude();
2359+
var amplitude2 = new AmplitudeClient();
23602360
amplitude2.init(apiKey);
23612361
assert.equal(amplitude2._sessionId, timestamp);
23622362
assert.equal(amplitude2.getSessionId(), timestamp);

test/tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
require('./cookiestorage.js');
99
require('./utm.js');
1010
require('./amplitude.js');
11+
require('./amplitude-client.js');
1112
require('./utils.js');
1213
require('./revenue.js');

0 commit comments

Comments
 (0)