fix tests, add golden command (#4486)

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
Jeremy Letto 2021-11-26 15:55:12 -06:00 committed by GitHub
parent 6ce346af4a
commit 6dc9f004ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 481 additions and 272 deletions

View file

@ -30,8 +30,8 @@ describe('KeepAliveService', () => {
promise = new Promise(resolve => resolvePing = resolve);
ping = (done) => promise.then(done);
checkReadyStateSpy = spyOn(socket, 'checkReadyState');
checkReadyStateSpy.and.returnValue(true);
checkReadyStateSpy = jest.spyOn(socket, 'checkReadyState');
checkReadyStateSpy.mockImplementation(() => true);
service.startPingLoop(interval, ping);
jest.advanceTimersByTime(interval);
@ -52,15 +52,15 @@ describe('KeepAliveService', () => {
});
it('should fire disconnected$ if lastPingPending is still true', () => {
spyOn(service.disconnected$, 'next');
jest.spyOn(service.disconnected$, 'next').mockImplementation(() => {});
jest.advanceTimersByTime(interval);
expect(service.disconnected$.next).toHaveBeenCalled();
});
it('should endPingLoop if socket is not open', () => {
spyOn(service, 'endPingLoop');
checkReadyStateSpy.and.returnValue(false);
jest.spyOn(service, 'endPingLoop').mockImplementation(() => {});
checkReadyStateSpy.mockImplementation(() => false);
resolvePing();
jest.advanceTimersByTime(interval);