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