add unit tests
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-24 11:14:24 +01:00
parent 7e938138ff
commit d7e144620e
23 changed files with 2766 additions and 17 deletions

View 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);
});
});