Skip to content

Commit

Permalink
fix(Idle): immediately ping and resume keepalive upon interrupting id…
Browse files Browse the repository at this point in the history
…le state
  • Loading branch information
grbsk committed Feb 16, 2016
1 parent 11bfb70 commit 62b47b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/idle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,26 @@ export function main() {
expect(instance.isRunning()).toBe(false);
expect(svc.isRunning).toBe(false);

instance.stop();
}));

it('should immediately ping and restart keepalive when user returns from idle', <any>fakeAsync((): void => {
spyOn(svc, 'ping').and.callThrough();
instance.watch();
expect(svc.isRunning).toBe(true);
tick(3000);

expect(instance.isIdling()).toBe(true);
expect(instance.isRunning()).toBe(true);
expect(svc.isRunning).toBe(false);

instance.interrupt();

expect(instance.isIdling()).toBe(false);
expect(instance.isRunning()).toBe(true);
expect(svc.isRunning).toBe(true);
expect(svc.ping).toHaveBeenCalled();

instance.stop();
}));
});
Expand Down
1 change: 1 addition & 0 deletions src/idle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export class Idle implements OnDestroy {
}
} else {
this.onIdleEnd.emit(null);
this.startKeepalive();
}

this.safeClearInterval('idleHandle');
Expand Down

0 comments on commit 62b47b2

Please sign in to comment.