101577: Added changes parameter to the ThumbnailComponent's ngOnChanges

This commit is contained in:
Alexandre Vryghem
2023-05-17 15:22:37 +02:00
parent 30cbcbb7c8
commit 0559e1ebc1
2 changed files with 9 additions and 9 deletions

View File

@@ -49,7 +49,7 @@ describe('ThumbnailComponent', () => {
comp.src = 'http://bit.stream'; comp.src = 'http://bit.stream';
comp.defaultImage = 'http://default.img'; comp.defaultImage = 'http://default.img';
comp.errorHandler(); comp.errorHandler();
comp.ngOnChanges(); comp.ngOnChanges({});
fixture.detectChanges(); fixture.detectChanges();
const image: HTMLElement = de.query(By.css('img')).nativeElement; const image: HTMLElement = de.query(By.css('img')).nativeElement;
expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt);
@@ -61,7 +61,7 @@ describe('ThumbnailComponent', () => {
comp.errorHandler(); comp.errorHandler();
expect(comp.src).toBe(null); expect(comp.src).toBe(null);
comp.ngOnChanges(); comp.ngOnChanges({});
fixture.detectChanges(); fixture.detectChanges();
const placeholder = fixture.debugElement.query(By.css('div.thumbnail-placeholder')).nativeElement; const placeholder = fixture.debugElement.query(By.css('div.thumbnail-placeholder')).nativeElement;
expect(placeholder.innerHTML).toBe('TRANSLATED ' + comp.placeholder); expect(placeholder.innerHTML).toBe('TRANSLATED ' + comp.placeholder);
@@ -84,7 +84,7 @@ describe('ThumbnailComponent', () => {
it('should display an image', () => { it('should display an image', () => {
comp.thumbnail = thumbnail; comp.thumbnail = thumbnail;
comp.ngOnChanges(); comp.ngOnChanges({});
fixture.detectChanges(); fixture.detectChanges();
const image: HTMLElement = de.query(By.css('img')).nativeElement; const image: HTMLElement = de.query(By.css('img')).nativeElement;
expect(image.getAttribute('src')).toBe(comp.thumbnail._links.content.href); expect(image.getAttribute('src')).toBe(comp.thumbnail._links.content.href);
@@ -92,7 +92,7 @@ describe('ThumbnailComponent', () => {
it('should include the alt text', () => { it('should include the alt text', () => {
comp.thumbnail = thumbnail; comp.thumbnail = thumbnail;
comp.ngOnChanges(); comp.ngOnChanges({});
fixture.detectChanges(); fixture.detectChanges();
const image: HTMLElement = de.query(By.css('img')).nativeElement; const image: HTMLElement = de.query(By.css('img')).nativeElement;
expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt);
@@ -113,7 +113,7 @@ describe('ThumbnailComponent', () => {
it('should show a loading animation', () => { it('should show a loading animation', () => {
comp.thumbnail = thumbnail; comp.thumbnail = thumbnail;
comp.ngOnChanges(); comp.ngOnChanges({});
fixture.detectChanges(); fixture.detectChanges();
expect(de.query(By.css('ds-loading'))).toBeTruthy(); expect(de.query(By.css('ds-loading'))).toBeTruthy();
}); });
@@ -134,7 +134,7 @@ describe('ThumbnailComponent', () => {
it('should display an image', () => { it('should display an image', () => {
comp.thumbnail = thumbnail; comp.thumbnail = thumbnail;
comp.ngOnChanges(); comp.ngOnChanges({});
fixture.detectChanges(); fixture.detectChanges();
const image: HTMLElement = de.query(By.css('img')).nativeElement; const image: HTMLElement = de.query(By.css('img')).nativeElement;
expect(image.getAttribute('src')).toBe(comp.thumbnail.payload._links.content.href); expect(image.getAttribute('src')).toBe(comp.thumbnail.payload._links.content.href);
@@ -142,7 +142,7 @@ describe('ThumbnailComponent', () => {
it('should display the alt text', () => { it('should display the alt text', () => {
comp.thumbnail = thumbnail; comp.thumbnail = thumbnail;
comp.ngOnChanges(); comp.ngOnChanges({});
fixture.detectChanges(); fixture.detectChanges();
const image: HTMLElement = de.query(By.css('img')).nativeElement; const image: HTMLElement = de.query(By.css('img')).nativeElement;
expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt);

View File

@@ -1,4 +1,4 @@
import { Component, Input, OnChanges } from '@angular/core'; import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { Bitstream } from '../core/shared/bitstream.model'; import { Bitstream } from '../core/shared/bitstream.model';
import { hasValue } from '../shared/empty.util'; import { hasValue } from '../shared/empty.util';
import { RemoteData } from '../core/data/remote-data'; import { RemoteData } from '../core/data/remote-data';
@@ -51,7 +51,7 @@ export class ThumbnailComponent implements OnChanges {
* Resolve the thumbnail. * Resolve the thumbnail.
* Use a default image if no actual image is available. * Use a default image if no actual image is available.
*/ */
ngOnChanges(): void { ngOnChanges(changes: SimpleChanges): void {
if (this.thumbnail === undefined || this.thumbnail === null) { if (this.thumbnail === undefined || this.thumbnail === null) {
return; return;
} }