jeudi 16 janvier 2020

How can I mock sweetalert and how do i make it return true on angular test

I want to write angular test on my typescript. My typescript code is like that

swal({
      title: "ONAY",
      text: `Delete this row?`,
      type: "warning",
      showConfirmButton: true,
      showCancelButton: true,
      confirmButtonText: "Delete",
      cancelButtonText: "Not Delete",
      confirmButtonColor: "#ef5350"
    }).then(isConfirm => {
   if (isConfirm.value != null && isConfirm.value) {
   //DO SOMETHING
}
    });

I want to write test on //DO SOMETHING expression but I don't reach this block because of sweetalert confirm window.

How can I mock sweetalert and how do i make it return true?

Aucun commentaire:

Enregistrer un commentaire