Testing window.location in jest

I am trying to test the window functionality via jest. I have a function which appends a query param to the url and redirects the page to the other page. A rough snippet of the code is below:

var url = new URL(targetUrl);
    if (typeof status !== undefined) {
      // base encode status
      url.searchParams.append("status", status);
      window.location = url.toString();

I am new to jest and I am facing a bit of difficulty simulating the mock test for this, hence can you please help me with this. Thanks in advance.