Skip to content

Commit

Permalink
feat(DH): Add tests for thumbnailUrl logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Angi-Kinas committed Jan 24, 2024
1 parent 77875c2 commit 1ba7227
Showing 1 changed file with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ export class MockMetadataCatalogComponent {
export class MockRecordApiFormComponent {
@Input() apiLink: DatasetServiceDistribution
}
@Component({
// eslint-disable-next-line @angular-eslint/component-selector
selector: 'gn-ui-image-overlay-preview',
template: '<div></div>',
})
export class MockImgOverlayPreviewComponent {
@Input() imageUrl: string
@Output() isPlaceholderShown = new EventEmitter<boolean>()
}

describe('RecordMetadataComponent', () => {
let component: RecordMetadataComponent
Expand All @@ -172,6 +181,7 @@ describe('RecordMetadataComponent', () => {
MockMetadataCatalogComponent,
MockMetadataContactComponent,
MockRecordApiFormComponent,
MockImgOverlayPreviewComponent,
],
schemas: [NO_ERRORS_SCHEMA],
imports: [TranslateModule.forRoot()],
Expand Down Expand Up @@ -267,6 +277,56 @@ describe('RecordMetadataComponent', () => {
fixture.debugElement.query(By.directive(MockMetadataCatalogComponent))
).toBeFalsy()
})
it('does not display the image overlay preview', () => {
expect(
fixture.debugElement.query(
By.directive(MockImgOverlayPreviewComponent)
)
).toBeFalsy()
})
})
describe('Image Overlay Preview', () => {
describe('if metadata without overview', () => {
let imgOverlayPreview: MockImgOverlayPreviewComponent
beforeEach(() => {
facade.isPresent$.next(true)
facade.metadata$.next({})
fixture.detectChanges()
imgOverlayPreview = fixture.debugElement.query(
By.directive(MockImgOverlayPreviewComponent)
).componentInstance
})
it('should send undefined as imageUrl to imgOverlayPreview component', () => {
expect(imgOverlayPreview).toBeTruthy()
expect(imgOverlayPreview.imageUrl).toBe(undefined)
})
})
describe('if metadata with overview', () => {
let imgOverlayPreview: MockImgOverlayPreviewComponent
beforeEach(() => {
facade.isPresent$.next(true)
fixture.detectChanges()
imgOverlayPreview = fixture.debugElement.query(
By.directive(MockImgOverlayPreviewComponent)
).componentInstance
})
describe('and url defined', () => {
it('should send the imageUrl to imgOverlayPreview component', () => {
expect(imgOverlayPreview).toBeTruthy()
expect(imgOverlayPreview.imageUrl).toBeDefined()
})
})
describe('and url undefined', () => {
beforeEach(() => {
facade.metadata$.next({ overviews: [] })
fixture.detectChanges()
})
it('should send the imagUrl as null to imgOverlayPreview component', () => {
expect(imgOverlayPreview).toBeTruthy()
expect(imgOverlayPreview.imageUrl).toBeNull()
})
})
})
})
})

Expand Down

0 comments on commit 1ba7227

Please sign in to comment.