|
18 | 18 | import {ComponentFixture, TestBed,} from '@angular/core/testing'; |
19 | 19 | import {MatDialog, MatDialogModule} from '@angular/material/dialog'; |
20 | 20 | import {NoopAnimationsModule} from '@angular/platform-browser/animations'; |
21 | | -// 1p-ONLY-IMPORTS: import {beforeEach, describe, it,} |
| 21 | +// 1p-ONLY-IMPORTS: import {beforeEach, describe, it, } |
22 | 22 | import {of} from 'rxjs'; |
23 | 23 |
|
24 | 24 | import {SESSION_SERVICE, SessionService,} from '../../core/services/interfaces/session'; |
@@ -125,4 +125,44 @@ describe('SessionTabComponent', () => { |
125 | 125 | }); |
126 | 126 | }); |
127 | 127 | }); |
| 128 | + |
| 129 | + describe('when reloading a session', () => { |
| 130 | + beforeEach(() => { |
| 131 | + spyOn(component.sessionReloaded, 'emit'); |
| 132 | + }); |
| 133 | + |
| 134 | + describe('when reloading a session is successful', () => { |
| 135 | + beforeEach(() => { |
| 136 | + sessionService.getSessionResponse.next({} as any); |
| 137 | + component.reloadSession('session1'); |
| 138 | + }); |
| 139 | + |
| 140 | + it('emits sessionReloaded', () => { |
| 141 | + expect(component.sessionReloaded.emit).toHaveBeenCalled(); |
| 142 | + }); |
| 143 | + }); |
| 144 | + |
| 145 | + describe('when reloading a session throws error', () => { |
| 146 | + beforeEach(() => { |
| 147 | + sessionService.getSessionResponse.error(new Error('error')); |
| 148 | + component.reloadSession('session1'); |
| 149 | + }); |
| 150 | + |
| 151 | + it('does not emit sessionReloaded', () => { |
| 152 | + expect(component.sessionReloaded.emit).not.toHaveBeenCalled(); |
| 153 | + }); |
| 154 | + |
| 155 | + describe('on retry', () => { |
| 156 | + beforeEach(() => { |
| 157 | + sessionService.getSession.calls.reset(); |
| 158 | + sessionService.getSessionResponse.next({} as any); |
| 159 | + component.reloadSession('session1'); |
| 160 | + }); |
| 161 | + |
| 162 | + it('fetches session again', () => { |
| 163 | + expect(sessionService.getSession).toHaveBeenCalled(); |
| 164 | + }); |
| 165 | + }); |
| 166 | + }); |
| 167 | + }); |
128 | 168 | }); |
0 commit comments