// Workaround for lack of `<dialog>` support in jsdom
// Workaround from: https://github.com/jsdom/jsdom/issues/3294#issuecomment-1268330372
// Fix: https://github.com/jsdom/jsdom/pull/3403
// This can be removed once `<dialog>` support is introduced in jsdom
export const htmlDialogPolyfill = () => {
  HTMLDialogElement.prototype.show = vi.fn(function mock(
    this: HTMLDialogElement,
  ) {
    this.open = true;
  });

  HTMLDialogElement.prototype.showModal = vi.fn(function mock(
    this: HTMLDialogElement,
  ) {
    this.open = true;
  });

  HTMLDialogElement.prototype.close = vi.fn(function mock(
    this: HTMLDialogElement,
  ) {
    this.open = false;
  });
};
