78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { SponsorSettingsViewModel } from './SponsorSettingsViewModel';
|
|
import { SponsorProfileViewModel } from './SponsorProfileViewModel';
|
|
import { NotificationSettingsViewModel } from './NotificationSettingsViewModel';
|
|
import { PrivacySettingsViewModel } from './PrivacySettingsViewModel';
|
|
|
|
describe('SponsorSettingsViewModel', () => {
|
|
const profile = {
|
|
companyName: 'Acme Corp',
|
|
contactName: 'John Doe',
|
|
contactEmail: 'john@example.com',
|
|
contactPhone: '+1234567890',
|
|
website: 'https://acme.example',
|
|
description: 'We sponsor racing',
|
|
logoUrl: '/logo.png',
|
|
industry: 'Automotive',
|
|
address: {
|
|
street: '123 Main St',
|
|
city: 'Metropolis',
|
|
country: 'US',
|
|
postalCode: '12345',
|
|
},
|
|
taxId: 'TAX-123',
|
|
socialLinks: {
|
|
twitter: '@acme',
|
|
linkedin: 'https://linkedin.com/acme',
|
|
instagram: '@acme_insta',
|
|
},
|
|
};
|
|
|
|
const notifications = {
|
|
emailNewSponsorships: true,
|
|
emailWeeklyReport: false,
|
|
emailRaceAlerts: true,
|
|
emailPaymentAlerts: false,
|
|
emailNewOpportunities: true,
|
|
emailContractExpiry: true,
|
|
};
|
|
|
|
const privacy = {
|
|
publicProfile: true,
|
|
showStats: false,
|
|
showActiveSponsorships: true,
|
|
allowDirectContact: false,
|
|
};
|
|
|
|
it('maps raw settings object into nested view models', () => {
|
|
const vm = new SponsorSettingsViewModel({ profile, notifications, privacy });
|
|
|
|
expect(vm.profile).toBeInstanceOf(SponsorProfileViewModel);
|
|
expect(vm.notifications).toBeInstanceOf(NotificationSettingsViewModel);
|
|
expect(vm.privacy).toBeInstanceOf(PrivacySettingsViewModel);
|
|
|
|
expect(vm.profile.companyName).toBe(profile.companyName);
|
|
expect(vm.notifications.emailNewSponsorships).toBe(true);
|
|
expect(vm.privacy.publicProfile).toBe(true);
|
|
});
|
|
|
|
it('exposes fullAddress computed from address fields', () => {
|
|
const profileVm = new SponsorProfileViewModel(profile);
|
|
|
|
expect(profileVm.fullAddress).toBe(
|
|
`${profile.address.street}, ${profile.address.city}, ${profile.address.postalCode}, ${profile.address.country}`,
|
|
);
|
|
});
|
|
|
|
it('preserves notification and privacy boolean flags', () => {
|
|
const notificationsVm = new NotificationSettingsViewModel(notifications);
|
|
const privacyVm = new PrivacySettingsViewModel(privacy);
|
|
|
|
expect(notificationsVm.emailWeeklyReport).toBe(false);
|
|
expect(notificationsVm.emailContractExpiry).toBe(true);
|
|
|
|
expect(privacyVm.showStats).toBe(false);
|
|
expect(privacyVm.allowDirectContact).toBe(false);
|
|
});
|
|
});
|