- Fix SettingsView/SegmentsView specs to match current dialog-based confirm flows instead of stale assumptions. - Fix FeatureDetail delete confirmation: deleteConfirmName was referenced but never declared, so the type-to-confirm gate was dead code with no input or disabled binding. - Extract the router's auth guard as authGuard so it can be tested directly instead of duplicated inline in specs; add missing allowAuthenticated and redirect-query coverage. - Add specs for previously untested modules: api/client.ts (401 refresh/retry/queueing), LoginView, RegisterView, AcceptInviteView, stores/theme.ts, utils/validation.ts, ConditionEditor, and RuleGroupEditor.
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { describe, it, expect } from '@jest/globals';
|
|
import { validateEmail } from '@/utils/validation';
|
|
|
|
describe('validateEmail', () => {
|
|
describe('WhenTheValueIsEmpty', () => {
|
|
it('ThenItReturnsAnEmailRequiredMessage', () => {
|
|
expect(validateEmail('')).toBe('Email required');
|
|
});
|
|
});
|
|
|
|
describe('WhenTheValueIsOnlyWhitespace', () => {
|
|
it('ThenItReturnsAnEmailRequiredMessage', () => {
|
|
expect(validateEmail(' ')).toBe('Email required');
|
|
});
|
|
});
|
|
|
|
describe('WhenTheValueIsAValidEmail', () => {
|
|
it('ThenItReturnsTrue', () => {
|
|
expect(validateEmail('jane@example.com')).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('WhenTheValueHasSurroundingWhitespace', () => {
|
|
it('ThenItIsTrimmedBeforeValidationAndReturnsTrue', () => {
|
|
expect(validateEmail(' jane@example.com ')).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('WhenTheValueIsMissingTheAtSymbol', () => {
|
|
it('ThenItReturnsAnInvalidEmailMessage', () => {
|
|
expect(validateEmail('jane.example.com')).toBe('Invalid email');
|
|
});
|
|
});
|
|
|
|
describe('WhenTheValueIsMissingTheDomain', () => {
|
|
it('ThenItReturnsAnInvalidEmailMessage', () => {
|
|
expect(validateEmail('jane@example')).toBe('Invalid email');
|
|
});
|
|
});
|
|
|
|
describe('WhenTheValueContainsSpaces', () => {
|
|
it('ThenItReturnsAnInvalidEmailMessage', () => {
|
|
expect(validateEmail('jane doe@example.com')).toBe('Invalid email');
|
|
});
|
|
});
|
|
|
|
describe('WhenTheValueHasMultipleAtSymbols', () => {
|
|
it('ThenItReturnsAnInvalidEmailMessage', () => {
|
|
expect(validateEmail('jane@doe@example.com')).toBe('Invalid email');
|
|
});
|
|
});
|
|
});
|