commit
ad708f78cd
|
@ -340,7 +340,9 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro
|
|||
ngOnDestroy(): void {
|
||||
this.undeleteEventObserver?.off();
|
||||
this.manager?.destroy();
|
||||
this.managerUnsubscribe && this.managerUnsubscribe();
|
||||
this.managerUnsubscribe?.();
|
||||
|
||||
delete this.manager;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -457,7 +457,9 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
this.filterChangedObserver?.off();
|
||||
this.manager?.getSource().forgetRelatedSources();
|
||||
this.manager?.destroy();
|
||||
this.managerUnsubscribe && this.managerUnsubscribe();
|
||||
this.managerUnsubscribe?.();
|
||||
|
||||
delete this.manager;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -314,8 +314,10 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy {
|
|||
* @inheritdoc
|
||||
*/
|
||||
ngOnDestroy(): void {
|
||||
this.managerUnsubscribe && this.managerUnsubscribe();
|
||||
this.manager?.destroy();
|
||||
this.managerUnsubscribe?.();
|
||||
|
||||
delete this.manager;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import { AlertController, Translate } from '@singletons';
|
|||
import { mock, mockSingleton, mockTranslate } from '@/testing/utils';
|
||||
import { CoreSiteError } from '@classes/errors/siteerror';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { OverlayEventDetail } from '@ionic/core';
|
||||
|
||||
describe('CoreDomUtilsProvider', () => {
|
||||
|
||||
|
@ -56,4 +57,30 @@ describe('CoreDomUtilsProvider', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('ignores alert inputs on cancel', async () => {
|
||||
// Arrange.
|
||||
const mockAlert = mock<HTMLIonAlertElement>({
|
||||
present: () => Promise.resolve(),
|
||||
onWillDismiss: () => Promise.resolve({
|
||||
data: {
|
||||
values: {
|
||||
'textarea-prompt': 'Not empty!',
|
||||
},
|
||||
},
|
||||
role: 'cancel',
|
||||
} as OverlayEventDetail<any>), // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
});
|
||||
|
||||
mockSingleton(AlertController, mock({ create: () => Promise.resolve(mockAlert) }));
|
||||
|
||||
// Act.
|
||||
const result = await domUtils.showTextareaPrompt('Age', 'How old are you?', [
|
||||
{ text: 'Cancel', role: 'cancel' },
|
||||
{ text: 'Save' },
|
||||
]);
|
||||
|
||||
// Assert.
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1659,6 +1659,10 @@ export class CoreDomUtilsProvider {
|
|||
|
||||
const result = await alert.onWillDismiss();
|
||||
|
||||
if (result.role === 'cancel') {
|
||||
return;
|
||||
}
|
||||
|
||||
return result.data?.values?.['textarea-prompt'];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue