mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
|
import * as assert from 'assert/strict';
|
||
|
import trackEvent from '../../../src/utils/analytics';
|
||
|
|
||
|
describe('trackEvent', function () {
|
||
|
it('calls posthog.capture with the correct event name and properties', function () {
|
||
|
const testEventName = 'Recommendation Added';
|
||
|
const testProps = {
|
||
|
oneClickSubscribe: true
|
||
|
};
|
||
|
|
||
|
window.posthog = {
|
||
|
capture: (eventName, props) => {
|
||
|
assert.equal(eventName, 'Recommendation Added');
|
||
|
assert.deepEqual(props, {
|
||
|
oneClickSubscribe: true
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
trackEvent(testEventName, testProps);
|
||
|
});
|
||
|
|
||
|
it('calls plausible with the correct event name and properties', function () {
|
||
|
const testEventName = 'Recommendation Added';
|
||
|
const testProps = {
|
||
|
oneClickSubscribe: true
|
||
|
};
|
||
|
|
||
|
window.plausible = (eventName, {props}) => {
|
||
|
assert.equal(eventName, 'Recommendation Added');
|
||
|
assert.deepEqual(props, {
|
||
|
oneClickSubscribe: true
|
||
|
});
|
||
|
};
|
||
|
|
||
|
trackEvent(testEventName, testProps);
|
||
|
});
|
||
|
});
|