Skip to content

Commit

Permalink
Add a unit test for activity creator for notify reward amount notific…
Browse files Browse the repository at this point in the history
…ation type
  • Loading branch information
ae2079 committed Jul 9, 2024
1 parent 1e979b9 commit 03bb403
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/services/notificationService.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { activityCreator } from './notificationService';
import { NOTIFICATIONS_EVENT_NAMES } from '../types/notifications';
import { expect } from 'chai';

describe('activityCreator', () => {
it('should create attributes for NOTIFY_REWARD_AMOUNT', () => {
const payload = {
round: 1,
date: '2024-06-01',
amount: '1000',
contractAddress: '0x123',
farm: 'Test Farm',
message: 'Test Message',
network: 'Test Network',
script: 'Test Script',
transactionHash: '0xabc',
email: '[email protected]'
};
const result = activityCreator(payload, NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT);
expect(JSON.stringify(result)).equal(JSON.stringify({
activities: [
{
activity_id: "act:cm:notify-reward-amount",
attributes: {
'int:cm:round': payload.round,
'str:cm:date': payload.date,
'str:cm:amount': payload.amount,
'str:cm:contractaddress': payload.contractAddress,
'str:cm:farm': payload.farm,
'str:cm:message': payload.message,
'str:cm:network': payload.network,
'str:cm:script': payload.script,
'str:cm:transactionhash': payload.transactionHash,
},
fields: {
'str::email': payload.email,
},
},
],
merge_by: ['str::email'],
}));
})
});
2 changes: 1 addition & 1 deletion src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { NOTIFICATIONS_EVENT_NAMES, ORTTO_EVENT_NAMES } from '../types/notificat
import { getEmailAdapter } from '../adapters/adapterFactory';
import { NOTIFICATION_CATEGORY } from '../types/general';

const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES) : any=> {
export const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES) : any=> {
let attributes;
switch (orttoEventName) {
case NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING:
Expand Down

0 comments on commit 03bb403

Please sign in to comment.