|
| 1 | +import {ComponentFixture, TestBed} from '@angular/core/testing'; |
| 2 | +import {provideNoopAnimations} from '@angular/platform-browser/animations'; |
| 3 | +import {provideRouter} from '@angular/router'; |
| 4 | +import {NgIconsModule} from '@ng-icons/core'; |
| 5 | +import { |
| 6 | + ionChevronBackOutline, |
| 7 | + ionChevronForwardOutline, |
| 8 | + ionCloseOutline, |
| 9 | + ionContractOutline, |
| 10 | + ionExpandOutline, |
| 11 | + ionInformationOutline, |
| 12 | + ionMenuOutline, |
| 13 | + ionPauseOutline, |
| 14 | + ionPlayOutline, |
| 15 | +} from '@ng-icons/ionicons'; |
| 16 | + |
| 17 | +import {ControlsLightboxComponent} from './controls.lightbox.gallery.component'; |
| 18 | +import {LightboxService} from '../lightbox.service'; |
| 19 | +import {FullScreenService} from '../../fullscreen.service'; |
| 20 | +import {AuthenticationService} from '../../../../model/network/authentication.service'; |
| 21 | +import {FileSizePipe} from '../../../../pipes/FileSizePipe'; |
| 22 | +import {DatePipe} from '@angular/common'; |
| 23 | + |
| 24 | +class MockLightboxService { |
| 25 | + controllersDimmed = false; |
| 26 | + slideshowSpeed = 5; |
| 27 | + captionAlwaysOn = false; |
| 28 | + facesAlwaysOn = false; |
| 29 | +} |
| 30 | + |
| 31 | +class MockFullScreenService { |
| 32 | + isFullScreenEnabled() { |
| 33 | + return false; |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +class MockAuthenticationService { |
| 38 | + canSearch() { |
| 39 | + return false; |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +describe('ControlsLightboxComponent - cursor visibility', () => { |
| 44 | + let component: ControlsLightboxComponent; |
| 45 | + let fixture: ComponentFixture<ControlsLightboxComponent>; |
| 46 | + |
| 47 | + beforeEach(async () => { |
| 48 | + await TestBed.configureTestingModule({ |
| 49 | + imports: [ |
| 50 | + ControlsLightboxComponent, |
| 51 | + NgIconsModule.withIcons({ |
| 52 | + ionInformationOutline, |
| 53 | + ionContractOutline, |
| 54 | + ionExpandOutline, |
| 55 | + ionMenuOutline, |
| 56 | + ionCloseOutline, |
| 57 | + ionChevronBackOutline, |
| 58 | + ionChevronForwardOutline, |
| 59 | + ionPlayOutline, |
| 60 | + ionPauseOutline, |
| 61 | + }), |
| 62 | + ], |
| 63 | + providers: [ |
| 64 | + {provide: LightboxService, useClass: MockLightboxService}, |
| 65 | + {provide: FullScreenService, useClass: MockFullScreenService}, |
| 66 | + {provide: AuthenticationService, useClass: MockAuthenticationService}, |
| 67 | + {provide: FileSizePipe, useValue: {}}, |
| 68 | + {provide: DatePipe, useValue: {}}, |
| 69 | + provideNoopAnimations(), |
| 70 | + provideRouter([]), |
| 71 | + ], |
| 72 | + }).compileComponents(); |
| 73 | + |
| 74 | + fixture = TestBed.createComponent(ControlsLightboxComponent); |
| 75 | + component = fixture.componentInstance; |
| 76 | + fixture.detectChanges(); |
| 77 | + }); |
| 78 | + |
| 79 | + it('should hide the cursor while the controls are dimmed', () => { |
| 80 | + component.controllersDimmed = true; |
| 81 | + fixture.detectChanges(); |
| 82 | + |
| 83 | + const swipeable: HTMLElement = fixture.nativeElement.querySelector('#swipeable-container'); |
| 84 | + expect(swipeable).toBeTruthy(); |
| 85 | + expect(swipeable.classList.contains('hide-cursor')).toBe(true); |
| 86 | + }); |
| 87 | + |
| 88 | + it('should keep the cursor visible while the controls are shown', () => { |
| 89 | + component.controllersDimmed = false; |
| 90 | + fixture.detectChanges(); |
| 91 | + |
| 92 | + const swipeable: HTMLElement = fixture.nativeElement.querySelector('#swipeable-container'); |
| 93 | + expect(swipeable).toBeTruthy(); |
| 94 | + expect(swipeable.classList.contains('hide-cursor')).toBe(false); |
| 95 | + }); |
| 96 | +}); |
0 commit comments