feat(componentes-test): add image modal demo
This commit is contained in:
@@ -83,6 +83,9 @@
|
||||
Abrir modal ancho
|
||||
</app-button>
|
||||
<app-button (click)="openSimpleModal()"> Abrir simple modal </app-button>
|
||||
<app-button variant="secondary" (click)="openImageModal()">
|
||||
Abrir visor de imagen
|
||||
</app-button>
|
||||
</div>
|
||||
<div class="modal-showcase__result" data-testid="modal-last-result">
|
||||
{{ lastModalResult }}
|
||||
|
||||
@@ -51,6 +51,7 @@ function createModalServiceStub() {
|
||||
open: vi.fn(),
|
||||
openConfirm: vi.fn().mockReturnValue(of(true)),
|
||||
openConfirmDelete: vi.fn().mockReturnValue(of(false)),
|
||||
openImage: vi.fn().mockReturnValue(of(undefined)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -281,6 +282,9 @@ describe('ReutilizablesTestPageComponent', () => {
|
||||
const deleteButton = buttons.find((button) =>
|
||||
button.textContent?.includes('Abrir confirm delete'),
|
||||
) as HTMLButtonElement;
|
||||
const imageButton = buttons.find((button) =>
|
||||
button.textContent?.includes('Abrir visor de imagen'),
|
||||
) as HTMLButtonElement;
|
||||
|
||||
expect(element.querySelector('[data-testid="modal-last-result"]')?.textContent).toContain(
|
||||
'Todavia no se abrio ningun modal.',
|
||||
@@ -290,6 +294,8 @@ describe('ReutilizablesTestPageComponent', () => {
|
||||
fixture.detectChanges();
|
||||
deleteButton.click();
|
||||
fixture.detectChanges();
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(modalServiceStub.openConfirm).toHaveBeenCalledWith({
|
||||
title: 'Confirmar accion',
|
||||
@@ -302,6 +308,11 @@ describe('ReutilizablesTestPageComponent', () => {
|
||||
'Esta accion eliminara el producto del catalogo. Podras volver a crearlo manualmente.',
|
||||
confirmLabel: 'Eliminar',
|
||||
});
|
||||
expect(modalServiceStub.openImage).toHaveBeenCalledWith({
|
||||
title: 'Mochila urbana roja',
|
||||
src: '/images/carousel-mochila-roja.webp',
|
||||
alt: 'Mochila urbana roja vista de frente',
|
||||
});
|
||||
expect(element.querySelector('[data-testid="modal-last-result"]')?.textContent).toContain(
|
||||
'Resultado: false',
|
||||
);
|
||||
|
||||
@@ -493,6 +493,14 @@ export class ReutilizablesTestPageComponent {
|
||||
});
|
||||
}
|
||||
|
||||
protected openImageModal(): void {
|
||||
this.modalService.openImage({
|
||||
title: 'Mochila urbana roja',
|
||||
src: '/images/carousel-mochila-roja.webp',
|
||||
alt: 'Mochila urbana roja vista de frente',
|
||||
});
|
||||
}
|
||||
|
||||
private openConfirmModal(config: Parameters<ModalService['openConfirm']>[0]): void {
|
||||
this.modalService.openConfirm(config).subscribe((confirmed) => {
|
||||
this.lastModalResult = `Resultado: ${confirmed}`;
|
||||
|
||||
Reference in New Issue
Block a user