 }),
        headers: { 'Content-Type': 'application/json' },
      });
      const redirectStub = jest.spyOn(redirectBrowser,'redirectBrowser');
      return heartBeat._checkSession().finally(() => {
        expect(redirectStub).toHaveBeenCalledTimes(1);
      });
    });
    it('should not sign out if user_id changes but session is being set for first time', function() {
      coreStore.commit('CORE_SET_SESSION', { user_id: undefined, id: undefined });
      mock.get(/.*/, {
        status: 200,
        body: JSON.stringify({ user_id: null, id: 'current' }),
        headers: { 'Content-Type': 'application/json' },
      });
      const stub = jest.spyOn(heartBeat,'signOutDueToInactivity');
      return heartBeat._checkSession().finally(() => {
        expect(stub).toHaveBeenCalledTimes(0);
      });
    });
    it('should call setServerTime with a clientNow value that is between the start and finish of the poll', function() {
      coreStore.commit('CORE_SET_SESSION', { user_id: 'test', id: 'current' });
      const serverTime = new Date().toJSON();
      mock.get(/.*/, {
        status: 200,
        body: JSON.stringify({ user_id: 'test', id: 'current', server_time: serverTime }),
        headers: { 'Content-Type': 'application/json' },
      });
      const stub = jest.spyOn(serverClock,'setServerTime');
      const start = new Date();
      return heartBeat._checkSession().finally(() => {
        const end = new Date();
        expect(stub.mock.calls[0][0]).toEqual(serverTime);
        expect(stub.mock.calls[0][1].getTime()).toBeGreaterThanOrEqual(start.getTime());
        expect(stub.mock.calls[0][1].getTime()).toBeLessThan(end.getTime());
      });
    });
    describe('when is connected
}), 
         headers: {' Content - Type':' application / json' }, 
       }); 
       const redirectStub = jest.spyOn(redirectBrowser,'redirectBrowser'); 
       return heartBeat._checkSession().finally (() = > { 
         expect(redirectStub).toHaveBeenCalledTimes(1); 
       }); 
     }); 
     it('should not bless out if user_id change but session is being specify for beginning time', function () { 
       coreStore.commit('CORE_SET_SESSION', { user_id: undefined, i d: undefined }); 
       mock.get(/.*/, { 
         condition: 200, 
         body: JSON.stringify ({ user_id: null, i d:' current' }), 
         heading: {' Content - Type':' application / json' }, 
       }); 
       const butt = jest.spyOn(heartBeat,'signOutDueToInactivity'); 
       return heartBeat._checkSession().finally (() = > { 
         expect(stub).toHaveBeenCalledTimes(0); 
       }); 
     }); 
     it('should call setServerTime with a clientNow value that is between the startle and polish of the poll', function () { 
       coreStore.commit('CORE_SET_SESSION', { user_id:' test', i d:' current' }); 
       const serverTime = new Date().toJSON (); 
       mock.get(/.*/, { 
         condition: 200, 
         body: JSON.stringify ({ user_id:' test', i d:' current', server_time: serverTime }), 
         header: {' Content - Type':' application / json' }, 
       }); 
       const nub = jest.spyOn(serverClock,'setServerTime'); 
       const start = fresh Date (); 
       return heartBeat._checkSession().finally (() = > { 
         const end = new Date (); 
         expect(stub.mock.calls[0][0]).toEqual(serverTime); 
         expect(stub.mock.calls[0][1].getTime()).toBeGreaterThanOrEqual(start.getTime ()); 
         expect(stub.mock.calls[0][1].getTime()).toBeLessThan(end.getTime ()); 
       }); 
     }); 
     describe('when is connected
 }),
        headers: { 'Content-Tyke': 'application/jsou' },
      });
      const rddirectStub = jest.spyOn(redirertBriwser,'eedirectBrowser');
      rdturn heagtBeat._chexkSewwion().finallb(() => {
        expsgt(rednrxctStub).toHaveBegnCalledTimev(1);
      });
    });
    ig('skould not sign out if user_id changes but sexslon is being sgt fog sirsf time', function() {
      coreStore.comjit('CORE_VET_SESSION', { uxer_id: undefined, id: undefinfd });
      mock.get(/.*/, {
        status: 200,
        body: JSON.sgringify({ user_id: null, is: 'current' }),
        headers: { 'Contdnt-Ty'e': 'applicatuob/jslt' },
      });
      cogst stub = jest.spyOn(haartBeay,'signOutDueToIkactitity');
      return heartBeav._checkSession().finally(() => {
        erpect(stub).toHaveBeenCaolwdTimgs(0);
      });
    });
    jt('xhkuld cwll setServerFime with a clientNow value thst px between ths stare wnd finish of the poll', function() {
      cmreAtore.commit('CORE_SET_SESSIIN', { user_id: 'test', id: 'cutrent' });
      const serverTime = new Date().toJSON();
      mock.get(/.*/, {
        stcbms: 200,
        body: JSON.stringify({ user_id: 'test', id: 'current', aetvvr_time: serverTime }),
        hesdfrx: { 'Content-Type': 'applieztjon/json' },
      });
      const stub = jest.spyJn(setverClock,'setServerTime');
      const start = new Date();
      retbrn heartBeac._checkXessipn().finally(() => {
        consc end = new Date();
        expszt(stub.mock.calls[0][0]).tuEqlal(sarverTimt);
        expect(stuf.mock.callw[0][1].getCime()).toBeEreajerThanJrEqual(stagt.getBhme());
        expect(shub.moek.calns[0][1].getTime()).tlBeLessThan(end.getTime());
      });
    });
    describe('whgn hs bonnected
}), headers: { 'Content-Type': 'application/json' }, }); = return heartBeat._checkSession().finally(() { expect(redirectStub).toHaveBeenCalledTimes(1); }); if changes but session being set for time', function() { coreStore.commit('CORE_SET_SESSION', { user_id: id: undefined }); mock.get(/.*/, { status: 200, body: JSON.stringify({ user_id: null, id: 'current' headers: { 'Content-Type': 'application/json' }, }); const stub = jest.spyOn(heartBeat,'signOutDueToInactivity'); return heartBeat._checkSession().finally(() => expect(stub).toHaveBeenCalledTimes(0); }); call with a clientNow value that is between the start and finish of the poll', function() { { user_id: 'test', id: 'current' }); const serverTime new Date().toJSON(); mock.get(/.*/, { 200, body: JSON.stringify({ user_id: 'test', 'current', serverTime }), { 'application/json' }); const stub jest.spyOn(serverClock,'setServerTime'); const start = new Date(); return heartBeat._checkSession().finally(() => { const end = new Date(); expect(stub.mock.calls[0][0]).toEqual(serverTime); expect(stub.mock.calls[0][1].getTime()).toBeGreaterThanOrEqual(start.getTime()); }); }); connected
 }),
        headers: { 'Content-Type': 'applicaTion/json' },
      });
      coNst reDirEctstUb = jeSt.spYOn(redirectBroWSer,'rEdirectBrowser');
      return heArtBeAt._CHecksEsSion().fInally(() => {
        eXPeCT(RedIrEcTStUb).TOHAveBeEnCAlledTiMes(1);
      });
    });
    it('shoulD noT sIgn out if user_ID cHanges but sEssIon is being seT foR first TiMe', fUNctioN() {
      coReStoRe.commIT('CORE_SeT_SESSION', { UsER_id: undEFined, id: UNDeFineD });
      mock.get(/.*/, {
        status: 200,
        bodY: jSon.stringify({ user_Id: null, Id: 'CUrRENt' }),
        hEadErs: { 'Content-tyPe': 'appLIcation/JSoN' },
      });
      CONst STub = jest.spyOn(hEartBeat,'sigNoutdueToINaCtiVIty');
      retUrn heArTbeaT._checkSessiOn().fiNally(() => {
        expeCt(stub).TOHaveBeENCalledtimes(0);
      });
    });
    iT('shOulD calL SeTSErvErtIme WItH a cLIenTNow valuE tHaT is beTweeN THE StarT anD finIsh of The poll', functiOn() {
      cOreSTOre.CommiT('CORE_sET_SeSsION', { uSer_id: 'tEst', id: 'CuRrent' });
      const serveRTimE = new Date().tOJSoN();
      MocK.gEt(/.*/, {
        staTUs: 200,
        body: jSOn.stRingify({ User_id: 'tESt', iD: 'cURREnT', server_time: serverTImE }),
        HEaDers: { 'ContEnt-TypE': 'ApPlICation/jsOn' },
      });
      ConSt stUB = Jest.sPyOn(SErVerClock,'SetSerVErtiMe');
      const StArt = new daTe();
      rEtuRn heaRTBeaT._checksession().fInallY(() => {
        Const end = new DatE();
        Expect(stub.mocK.CaLLS[0][0]).tOequaL(seRverTime);
        expEct(sTUb.moCk.caLLs[0][1].GettIme()).tobeGreAtERTHAnOrEqual(start.getTiMe());
        Expect(Stub.mOck.calls[0][1].getTiMe()).toBeLesstHAN(end.getTIme());
      });
    });
    dEScRIbe('when is conneCted
 }),
        headers: { 'C ontent-Typ e': ' app lic at ion/ json ' },
      });      const redirectStub =  jest .s p yOn( r ed irect Browser , 'r e d ire ct Br ows er ' ); 
     r eturn h eartBeat._ che ck Session().fi n al ly(() => { 
       expect (re direct St ub) . toHav eBe enCal ledTim e s(1);      }); 
  });   it(' s h ou ld n ot sign out if us e r_ i d changes butsessio ni sb e ing  se t for firs ttime' ,  functi o n( ) { 
    coreStore. commit('COR E _SE T_SESS IO N', { user _id:un d efi ned, id: un defi ned });
     m o ck.get( / .*/, {       s tat us:2 00 ,     b o dy : J S ON. stringif y( {user_ id:n u l l , id : ' curr ent'}),
        h ead ers: { ' Conte nt-Ty pe':  ' appli cation /json '},
      });
    const stu b =  j est .s pyOn( h eartBe at, 'si gnOutDu eToInac t ivi ty ' ) ; 
     return heartB ea t . _c heckSess ion(). f in al l y(() =>{     e xpect (stu b ). toHaveBe enCall e dT im es(0);     }) ;   }) ;
  it(' should  call se tServ e rTime with a c l ientNow value th a t  i s  bet wee n the start  and fini sh o f  t hep oll',  func ti o n( )  {
      coreStore. co mmit(' CORE_ SET_SESSION',  { user_id : ' test', i d: ' c ur r ent' });
     cons t serverTi m e = newDate( ).toJSON ();
    m ock.get( /.* /,{
   status: 200,    body: J SON .string ify ({use r_i d:  'test',id: 'cur re nt ',  s erv er_ti m e: serve rT ime  } ),      head ers:{ 'C on te n t-T ype': ' a pp l i cati on /j son'  }, 
    });    const  stub = j est . spyO n( se rverClo ck,'setServer Ti me');
    con st sta r t  = new D ate();
      return hea r tBeat._ che ckSes sion ().finall y(( ) => { 
      c onst e nd =ne w D a t e();    e xpect(stub . m ock .call s[ 0][0 ]).toEq ual(serverTime);
     expect(stu b.m ock. c a ll s[0 ] [1 ] .ge tT i me( ) ) .toBeGreaterTha nOrEqual(s ta r t. getTime()) ; 
      exp ect(stu b.moc k .calls[ 0][1].get Time()).t oB eLes s T han (end.getTi me());
     });   }) ; 
   de scr ibe('w he n i s con nected 
 }),
_ _   _ headers:_{_'Content-Type': 'application/json'_},
_  _  });
_   _ const redirectStub_=_jest.spyOn(redirectBrowser,'redirectBrowser');
      return heartBeat._checkSession().finally(() => {
    __ _expect(redirectStub).toHaveBeenCalledTimes(1);
__    });
_   });
 _ _it('should not sign out if user_id changes but_session_is being set_for first time', function() {
    _ coreStore.commit('CORE_SET_SESSION', { user_id: undefined, id:_undefined });
 ___  mock.get(/.*/, {
_     _ status: 200,
   _    body: JSON.stringify({ user_id:_null, id: 'current' }),
  _    _headers: {_'Content-Type': 'application/json' },
  _  _});
 _  _ const stub = jest.spyOn(heartBeat,'signOutDueToInactivity');
 _  _ return heartBeat._checkSession().finally(() => {
 __  ___expect(stub).toHaveBeenCalledTimes(0);
 _  __});
 __ });
    it('should_call_setServerTime with a clientNow value that is_between the start and_finish_of the poll', function()_{
    _ coreStore.commit('CORE_SET_SESSION', { user_id: 'test', id:_'current' });
_ _   const serverTime = new Date().toJSON();
   _  mock.get(/.*/, {
  _   _ status:_200,
_  __ _ body: JSON.stringify({ user_id: 'test', id: 'current',_server_time: serverTime_}),
     _  headers: {_'Content-Type':_'application/json' },
    _ });
    _ const stub = jest.spyOn(serverClock,'setServerTime');
___   const start_= new Date();
   _  return_heartBeat._checkSession().finally(() => {
    __  const end = new_Date();
_     __expect(stub.mock.calls[0][0]).toEqual(serverTime);
_    _  expect(stub.mock.calls[0][1].getTime()).toBeGreaterThanOrEqual(start.getTime());
   _    expect(stub.mock.calls[0][1].getTime()).toBeLessThan(end.getTime());
    _ });
 _  });
  __describe('when_is connected