Skip to content

Commit f293224

Browse files
committed
fix: add test cases
1 parent 629677f commit f293224

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

__tests__/notifications/index.ts

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ describe('generateNotification', () => {
12241224
expect(actual.notification.uniqueKey).toEqual(userId);
12251225
expect(actual.notification.icon).toEqual('Opportunity');
12261226
expect(actual.notification.title).toEqual(
1227-
'New opportunity waiting for you in daily.dev',
1227+
'New opportunity waiting for you',
12281228
);
12291229
expect(actual.notification.description).toEqual(
12301230
'<span><strong class="text-accent-cabbage-default">Why this is a match:</strong> Based on your React and TypeScript skills</span>',
@@ -2066,3 +2066,64 @@ describe('poll result notifications', () => {
20662066
);
20672067
});
20682068
});
2069+
2070+
describe('warm intro notifications', () => {
2071+
beforeEach(async () => {
2072+
jest.resetAllMocks();
2073+
await saveFixtures(con, User, usersFixture);
2074+
});
2075+
2076+
it('should generate warm_intro notification', async () => {
2077+
const type = NotificationType.WarmIntro;
2078+
const recruiter = usersFixture[1] as Reference<User>;
2079+
const organization = {
2080+
id: '550e8400-e29b-41d4-a716-446655440000',
2081+
name: 'Daily Dev Inc',
2082+
image: 'https://example.com/logo.png',
2083+
};
2084+
2085+
const ctx = {
2086+
userIds: ['1'],
2087+
opportunityId: '550e8400-e29b-41d4-a716-446655440001',
2088+
description: 'Warm introduction for opportunity',
2089+
recruiter,
2090+
organization,
2091+
};
2092+
2093+
const actual = generateNotificationV2(type, ctx);
2094+
expect(actual.notification.type).toEqual(type);
2095+
expect(actual.userIds).toEqual(['1']);
2096+
expect(actual.notification.public).toEqual(true);
2097+
expect(actual.notification.referenceId).toEqual(
2098+
'550e8400-e29b-41d4-a716-446655440001',
2099+
);
2100+
expect(actual.notification.referenceType).toEqual('opportunity');
2101+
expect(actual.notification.icon).toEqual('Opportunity');
2102+
expect(actual.notification.title).toEqual(
2103+
`We just sent an intro email to you and <b>${recruiter.name}</b> from <b>${organization.name}</b>!`,
2104+
);
2105+
expect(actual.notification.description).toEqual(
2106+
`<span>We reached out to them and received a positive response. Our team will be here to assist you with anything you need. <a href="mailto:[email protected]" target="_blank" class="text-text-link">contact us</a></span>`,
2107+
);
2108+
expect(actual.notification.targetUrl).toEqual('system');
2109+
expect(actual.notification.uniqueKey).toEqual('1');
2110+
expect(actual.avatars).toEqual([
2111+
{
2112+
image: organization.image,
2113+
name: organization.name,
2114+
referenceId: organization.id,
2115+
targetUrl:
2116+
'http://localhost:5002/settings/organization/550e8400-e29b-41d4-a716-446655440000',
2117+
type: 'organization',
2118+
},
2119+
{
2120+
image: recruiter.image,
2121+
name: recruiter.name,
2122+
referenceId: recruiter.id,
2123+
targetUrl: `http://localhost:5002/${recruiter.username}`,
2124+
type: 'user',
2125+
},
2126+
]);
2127+
expect(actual.attachments.length).toEqual(0);
2128+
});
2129+
});

src/notifications/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export const notificationTitleMap: Record<
196196
new_user_welcome: systemTitle,
197197
announcements: systemTitle,
198198
in_app_purchases: systemTitle,
199-
new_opportunity_match: () => `New opportunity waiting for you in daily.dev`,
199+
new_opportunity_match: () => `New opportunity waiting for you`,
200200
post_analytics: (ctx: NotificationPostAnalyticsContext) => {
201201
return `Your post has reached ${formatMetricValue(ctx.analytics.impressions)} impressions so far. <span class="text-text-link">View more analytics</span>`;
202202
},
@@ -590,7 +590,7 @@ export const generateNotificationMap: Record<
590590
.avatarOrganization(ctx.organization)
591591
.avatarUser(ctx.recruiter)
592592
.description(
593-
`<span>We reached out to them and received a positive response. Our team will be here to assist you with anything you need. <a href="" class="text-text-link">contact us</a></span>`,
593+
`<span>We reached out to them and received a positive response. Our team will be here to assist you with anything you need. <a href="mailto:[email protected]" target="_blank" class="text-text-link">contact us</a></span>`,
594594
);
595595
},
596596
};

0 commit comments

Comments
 (0)