I am working on a react-native-web application, the application has a logic something like this
return typeof Window !== 'undefined' ? ComponentA : ComponentB
now I am writing the test case for it, I am trying to mock the global.Window I need to mock it to be undefined once and have the Window once.
const originalWindow = {...global.Window};
it('Should not have Window', () => {
global.Window = undefined;
console.log('global.Window: ', global.Window);
});
it('Should have window', () => {
global.window = originalWindow
console.log('window is present: ', Search);
});
but in the second testCase the window is still undefined, what is the way around?