Fix stale admin specs and expand Jest coverage
- 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.
This commit is contained in:
52
src/admin/tests/unit/utils/validation.spec.ts
Normal file
52
src/admin/tests/unit/utils/validation.spec.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user