30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { RecordPageViewInputViewModel } from './RecordPageViewInputViewModel';
|
|
|
|
describe('RecordPageViewInputViewModel', () => {
|
|
it('maps basic fields from input data', () => {
|
|
const vm = new RecordPageViewInputViewModel({ path: '/home', userId: 'user-1' });
|
|
|
|
expect(vm.path).toBe('/home');
|
|
expect(vm.userId).toBe('user-1');
|
|
});
|
|
|
|
it('normalizes displayPath to always start with a slash', () => {
|
|
const withLeadingSlash = new RecordPageViewInputViewModel({ path: '/dashboard' });
|
|
const withoutLeadingSlash = new RecordPageViewInputViewModel({ path: 'settings' });
|
|
|
|
expect(withLeadingSlash.displayPath).toBe('/dashboard');
|
|
expect(withoutLeadingSlash.displayPath).toBe('/settings');
|
|
});
|
|
|
|
it('detects when user context is present', () => {
|
|
const withUser = new RecordPageViewInputViewModel({ path: '/', userId: 'user-1' });
|
|
const withoutUser = new RecordPageViewInputViewModel({ path: '/' });
|
|
const emptyUserId = new RecordPageViewInputViewModel({ path: '/', userId: '' });
|
|
|
|
expect(withUser.hasUserContext).toBe(true);
|
|
expect(withoutUser.hasUserContext).toBe(false);
|
|
expect(emptyUserId.hasUserContext).toBe(false);
|
|
});
|
|
});
|