1 import { getContactGroupsDelayedSaveChanges } from '@proton/shared/lib/contacts/helpers/contactGroup';
2 import type { MailSettings } from '@proton/shared/lib/interfaces';
3 import type { ContactEmail } from '@proton/shared/lib/interfaces/contacts';
4 import { MAX_RECIPIENTS } from '@proton/shared/lib/mail/mailSettings';
6 const group1 = 'group1';
8 const getUserContactEmails = (numberOfContacts: number) => {
9 const contactEmails: ContactEmail[] = [];
11 for (let i = 0; i < numberOfContacts; i++) {
12 const contact = { ID: `contact${i}`, Email: `email${i}@pm.me`, LabelIDs: [group1] } as ContactEmail;
13 contactEmails.push(contact);
19 const initialModel = {
31 const onLimitReached = jasmine.createSpy();
33 describe('contactGroups', () => {
34 describe('getContactGroupsDelayedSaveChanges', () => {
35 it('should be possible to add the contact to the contact group', () => {
36 const userContactEmails = getUserContactEmails(99);
38 const updatedChanges = getContactGroupsDelayedSaveChanges({
44 mailSettings: { RecipientLimit: MAX_RECIPIENTS } as MailSettings,
47 expect(updatedChanges).toEqual(changes);
51 describe('getContactGroupsDelayedSaveChanges', () => {
52 it('should not be possible to add the contact to the contact group', () => {
53 const userContactEmails = getUserContactEmails(100);
55 const updatedChanges = getContactGroupsDelayedSaveChanges({
61 mailSettings: {} as MailSettings,
64 expect(updatedChanges).toEqual({});
65 expect(onLimitReached).toHaveBeenCalled();