This commit is contained in:
46
tests/utils/verifiedEmail.test.ts
Normal file
46
tests/utils/verifiedEmail.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user