Commit 50ac47f6 authored by Morten Nordseth's avatar Morten Nordseth
Browse files

fix navigation error for jest

parent 70ab2670
Pipeline #115337 passed with stages
in 54 seconds
...@@ -40,7 +40,8 @@ async function updateUser(){ ...@@ -40,7 +40,8 @@ async function updateUser(){
let currentUser = await getCurrentUser(); let currentUser = await getCurrentUser();
let response = await sendRequest("PATCH", `${HOST}/api/users/${currentUser.id}/`, userForm, ""); let response = await sendRequest("PATCH", `${HOST}/api/users/${currentUser.id}/`, userForm, "");
if (response.ok) { if (response.ok) {
await fillForm(); //await fillForm();
window.location.replace("userprofile.html");
} else { } else {
let data = await response.json(); let data = await response.json();
let alert = createAlert("Could not update user!", data); let alert = createAlert("Could not update user!", data);
......
...@@ -58,6 +58,10 @@ describe("userprofile test", () => { ...@@ -58,6 +58,10 @@ describe("userprofile test", () => {
}); });
it("changes are saved", async () => { it("changes are saved", async () => {
//Fix for navigation error ref. https://github.com/jsdom/jsdom/issues/2112
delete window.location
window.location = { replace: jest.fn() }
window.document.querySelector('#inputEmail').value = "test@test.no"; window.document.querySelector('#inputEmail').value = "test@test.no";
await updateUser(); await updateUser();
window.document.documentElement.innerHTML = html.toString(); window.document.documentElement.innerHTML = html.toString();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment