Skip to content

Commit

Permalink
Tests for Anon Transaction events.
Browse files Browse the repository at this point in the history
Signed-off-by: Olusegun Akintayo <[email protected]>
  • Loading branch information
segun authored and Olusegun Akintayo committed Sep 25, 2023
1 parent 54e54a2 commit 969beae
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions app/scripts/controllers/metametrics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,80 @@ describe('MetaMetricsController', function () {
});
});

describe('Change Transaction XXX anonymous event namnes', function () {
it('should change "Transaction Added" anonymous event names to "Transaction Added Anon"', function () {
const metaMetricsController = getMetaMetricsController();
const spy = sinon.spy(segment, 'track');
metaMetricsController.submitEvent({
event: 'Transaction Added',
category: 'Unit Test',
sensitiveProperties: { foo: 'bar' },
});
assert.ok(spy.calledTwice);
assert.ok(
spy.calledWith({
event: `Transaction Added Anon`,
anonymousId: METAMETRICS_ANONYMOUS_ID,
context: DEFAULT_TEST_CONTEXT,
properties: {
foo: 'bar',
...DEFAULT_EVENT_PROPERTIES,
},
messageId: Utils.generateRandomId(),
timestamp: new Date(),
}),
);
});

it('should change "Transaction Submitted" anonymous event names to "Transaction Added Anon"', function () {
const metaMetricsController = getMetaMetricsController();
const spy = sinon.spy(segment, 'track');
metaMetricsController.submitEvent({
event: 'Transaction Submitted',
category: 'Unit Test',
sensitiveProperties: { foo: 'bar' },
});
assert.ok(spy.calledTwice);
assert.ok(
spy.calledWith({
event: `Transaction Submitted Anon`,
anonymousId: METAMETRICS_ANONYMOUS_ID,
context: DEFAULT_TEST_CONTEXT,
properties: {
foo: 'bar',
...DEFAULT_EVENT_PROPERTIES,
},
messageId: Utils.generateRandomId(),
timestamp: new Date(),
}),
);
});

it('should change "Transaction Finalized" anonymous event names to "Transaction Added Anon"', function () {
const metaMetricsController = getMetaMetricsController();
const spy = sinon.spy(segment, 'track');
metaMetricsController.submitEvent({
event: 'Transaction Finalized',
category: 'Unit Test',
sensitiveProperties: { foo: 'bar' },
});
assert.ok(spy.calledTwice);
assert.ok(
spy.calledWith({
event: `Transaction Finalized Anon`,
anonymousId: METAMETRICS_ANONYMOUS_ID,
context: DEFAULT_TEST_CONTEXT,
properties: {
foo: 'bar',
...DEFAULT_EVENT_PROPERTIES,
},
messageId: Utils.generateRandomId(),
timestamp: new Date(),
}),
);
});
});

describe('trackPage', function () {
it('should track a page view', function () {
const mock = sinon.mock(segment);
Expand Down

0 comments on commit 969beae

Please sign in to comment.