Files
kami-parse-server/spec/Analytics.spec.js
Florent Vilmart b754d51e8e chore(package): update jasmine to version 3.0.0 (#4553)
* chore(package): update jasmine to version 3.0.0

Closes #4547

* Fixes failing tests for jasmine 3.0

Starting 3.0, done(something) will fail

* Update tests so they dont leverage var, but let and const

With jasmine 3.0, the randomization engine was making the test fails because of the scope of `var`

* Remove randomizer

* Use same adapter for PG tests, drop table to ensure the tests dont side effect
2018-02-17 09:55:30 -05:00

62 lines
1.5 KiB
JavaScript

const analyticsAdapter = {
appOpened: function() {},
trackEvent: function() {}
}
describe('AnalyticsController', () => {
it('should track a simple event', (done) => {
spyOn(analyticsAdapter, 'trackEvent').and.callThrough();
reconfigureServer({
analyticsAdapter
}).then(() => {
return Parse.Analytics.track('MyEvent', {
key: 'value',
count: '0'
})
}).then(() => {
expect(analyticsAdapter.trackEvent).toHaveBeenCalled();
const lastCall = analyticsAdapter.trackEvent.calls.first();
const args = lastCall.args;
expect(args[0]).toEqual('MyEvent');
expect(args[1]).toEqual({
dimensions: {
key: 'value',
count: '0'
}
});
done();
}, (err) => {
fail(JSON.stringify(err));
done();
})
});
it('should track a app opened event', (done) => {
spyOn(analyticsAdapter, 'appOpened').and.callThrough();
reconfigureServer({
analyticsAdapter
}).then(() => {
return Parse.Analytics.track('AppOpened', {
key: 'value',
count: '0'
})
}).then(() => {
expect(analyticsAdapter.appOpened).toHaveBeenCalled();
const lastCall = analyticsAdapter.appOpened.calls.first();
const args = lastCall.args;
expect(args[0]).toEqual({
dimensions: {
key: 'value',
count: '0'
}
});
done();
}, (err) => {
fail(JSON.stringify(err));
done();
})
})
})