All checks were successful
continuous-integration/drone/push Build is passing
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { shouldShowVerifiedEmailBadge } from '../../src/utils/verifiedEmail';
|
|
|
|
describe('shouldShowVerifiedEmailBadge', () => {
|
|
it('returns false when email has not been verified', () => {
|
|
expect(
|
|
shouldShowVerifiedEmailBadge({
|
|
verifiedAt: null,
|
|
persistedEmail: 'a@example.com',
|
|
currentEmail: 'a@example.com',
|
|
isEditing: false,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it('returns true when verified and not editing', () => {
|
|
expect(
|
|
shouldShowVerifiedEmailBadge({
|
|
verifiedAt: '2025-01-01T10:00:00Z',
|
|
persistedEmail: 'a@example.com',
|
|
currentEmail: 'other@example.com',
|
|
isEditing: false,
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
it('while editing, returns true only when trimmed current email matches persisted email', () => {
|
|
expect(
|
|
shouldShowVerifiedEmailBadge({
|
|
verifiedAt: '2025-01-01T10:00:00Z',
|
|
persistedEmail: 'a@example.com',
|
|
currentEmail: ' a@example.com ',
|
|
isEditing: true,
|
|
}),
|
|
).toBe(true);
|
|
|
|
expect(
|
|
shouldShowVerifiedEmailBadge({
|
|
verifiedAt: '2025-01-01T10:00:00Z',
|
|
persistedEmail: 'a@example.com',
|
|
currentEmail: 'other@example.com',
|
|
isEditing: true,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
});
|