2024-01-29 07:15:30 -08:00
|
|
|
import validator from 'validator';
|
2024-09-12 09:07:18 -07:00
|
|
|
|
2024-08-28 08:57:46 -07:00
|
|
|
import type { User } from '@/databases/entities/user';
|
2024-09-12 09:07:18 -07:00
|
|
|
|
2024-01-29 07:15:30 -08:00
|
|
|
import type { UserInvitationResult } from '../../shared/utils/users';
|
|
|
|
|
|
|
|
export function assertReturnedUserProps(user: User) {
|
|
|
|
expect(validator.isUUID(user.id)).toBe(true);
|
|
|
|
expect(user.email).toBeDefined();
|
|
|
|
expect(user.personalizationAnswers).toBeNull();
|
|
|
|
expect(user.password).toBeUndefined();
|
|
|
|
expect(user.isPending).toBe(false);
|
|
|
|
expect(user.globalScopes).toBeDefined();
|
|
|
|
expect(user.globalScopes).not.toHaveLength(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
export const assertStoredUserProps = (user: User) => {
|
|
|
|
expect(user.firstName).toBeNull();
|
|
|
|
expect(user.lastName).toBeNull();
|
|
|
|
expect(user.personalizationAnswers).toBeNull();
|
|
|
|
expect(user.password).toBeNull();
|
|
|
|
expect(user.isPending).toBe(true);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const assertUserInviteResult = (data: UserInvitationResult) => {
|
|
|
|
expect(validator.isUUID(data.user.id)).toBe(true);
|
|
|
|
expect(data.user.inviteAcceptUrl).toBeUndefined();
|
|
|
|
expect(data.user.email).toBeDefined();
|
|
|
|
expect(data.user.emailSent).toBe(true);
|
|
|
|
};
|