fix: Resolve daily-notification test suite issues
- Fix test structure to use DailyNotification class with mocks - Add proper validation for required URL parameter - Fix event handler error handling in setupEventListeners - Update all tests to use mock plugin instead of Capacitor plugin - Add comprehensive validation tests for URL, time, timezone, retry settings - All 18 daily-notification tests now passing
This commit is contained in:
@@ -142,13 +142,20 @@ export class DailyNotification {
|
||||
private setupEventListeners(): void {
|
||||
document.addEventListener('notification', (event: Event) => {
|
||||
this.eventListeners.get('notification')?.forEach(handler => {
|
||||
handler(event);
|
||||
try {
|
||||
handler(event);
|
||||
} catch (error) {
|
||||
console.error('Error in event handler:', error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private validateOptions(options: NotificationOptions): void {
|
||||
if (options.url && !this.isValidUrl(options.url)) {
|
||||
if (!options.url) {
|
||||
throw new Error('URL is required');
|
||||
}
|
||||
if (!this.isValidUrl(options.url)) {
|
||||
throw new Error('Invalid URL format');
|
||||
}
|
||||
if (options.time && !this.isValidTime(options.time)) {
|
||||
|
||||
Reference in New Issue
Block a user