Skip to content

Commit 6290474

Browse files
committed
119602: Add accessibility-settings.service tests for cookie functionality
1 parent 4c30e2d commit 6290474

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/app/accessibility/accessibility-settings.service.spec.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,28 @@ describe('accessibilitySettingsService', () => {
350350
cookieService.remove = jasmine.createSpy('remove');
351351
});
352352

353+
it('should fail to store settings in the cookie when the user has not accepted the cookie', fakeAsync(() => {
354+
klaroService.getSavedPreferences.and.returnValue(of({ accessibility: false }));
355+
356+
service.setSettingsInCookie({ ['liveRegionTimeOut']: '500' }).subscribe(value => {
357+
expect(value).toEqual('failed');
358+
});
359+
flush();
360+
expect(cookieService.set).not.toHaveBeenCalled();
361+
}));
362+
353363
it('should store the settings in a cookie', fakeAsync(() => {
354-
service.setSettingsInCookie({ ['liveRegionTimeOut']: '500' }).subscribe();
364+
service.setSettingsInCookie({ ['liveRegionTimeOut']: '500' }).subscribe(value => {
365+
expect(value).toEqual('cookie');
366+
});
355367
flush();
356368
expect(cookieService.set).toHaveBeenCalled();
357369
}));
358370

359371
it('should remove the cookie when the settings are empty', fakeAsync(() => {
360-
service.setSettingsInCookie({}).subscribe();
372+
service.setSettingsInCookie({}).subscribe(value => {
373+
expect(value).toEqual('cookie');
374+
});
361375

362376
flush();
363377

0 commit comments

Comments
 (0)