import { isMobileDevice } from './device-detect';

describe('Device Detect Helper', () => {
  const { navigator } = window;

  beforeAll(() => {
    delete window.navigator;
    window.navigator = { userAgent: '' };
    jest.resetModules(); // this is important - it clears the cache
  });

  // afterAll(() => {
  //   // delete window.navigator;
  //   window.location = navigator;
  // });

  test('isMobileDevice()', () => {
    const mobile = isMobileDevice();
    expect(typeof mobile).toEqual('boolean');
    expect(mobile).toBeFalsy();
    window.navigator.userAgent = 'Android';
    expect(isMobileDevice()).toBeTruthy();
  });
});
