Note Jest uses global not window for the global object within your test files.
In your test, you assert what the value is in your mock local storage initially, then run the function, and assert what it should be afterwards.
If you start the mock with a non-null/undefined value, then the value after running your function should then be the same in both storages (I assume).
If you start the mock with null/undefined, then the value after running the function (with different values for global.name) should be what you expect (eg if you set global.name = 'Foobar' and storages are both null/undefined, the storage should be "John" post-function execution).
Repeat for all possible branches.
I’m only assuming changeName is supposed to update both storages. Also setting the window.name will likely break anything that relies on that browser API (which is not much afaics). Also imo you have far too many conditionals there, so you’re going to have to write loads of tests to cover each branch, and the John/Jane/Mark bit is needless repetition, this is a good use of testing to refactor because you’ll start to get bored with repeating yourself in the tests and lose track