[AAE-10778] Fix unit test: expect for internalFileName value instead of display-name id because the display name logic has been moved to the alfresco-viewer.component

This commit is contained in:
Amedeo Lepore
2022-12-19 10:33:58 +01:00
parent 38143e2ca1
commit dbffaded66

View File

@@ -410,46 +410,34 @@ describe('ViewerComponent', () => {
describe('display name property override by urlFile', () => { describe('display name property override by urlFile', () => {
it('should displayName override the default name if is present and urlFile is set', (done) => { it('should fileName override the default name if is present and urlFile is set', () => {
component.urlFile = 'fake-test-file.pdf'; component.urlFile = 'fake-test-file.pdf';
component.fileName = 'test name'; component.fileName = 'test name';
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges(); component.ngOnChanges();
fixture.whenStable().then(() => { expect(component.internalFileName).toEqual('test name');
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('test name');
done();
});
}); });
it('should use the urlFile name if displayName is NOT set and urlFile is set', (done) => { it('should use the urlFile name if fileName is NOT set and urlFile is set', () => {
component.urlFile = 'fake-test-file.pdf'; component.urlFile = 'fake-test-file.pdf';
component.fileName = null; component.fileName = '';
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges(); component.ngOnChanges();
fixture.whenStable().then(() => { expect(component.internalFileName).toEqual('fake-test-file.pdf');
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('fake-test-file.pdf');
done();
});
}); });
}); });
describe('display name property override by blobFile', () => { describe('display name property override by blobFile', () => {
it('should displayName override the name if is present and blobFile is set', (done) => { it('should fileName override the name if is present and blobFile is set', () => {
component.fileName = 'blob file display name'; component.fileName = 'blob file display name';
component.blobFile = new Blob(['This is my blob content'], {type: 'text/plain'}); component.blobFile = new Blob(['This is my blob content'], {type: 'text/plain'});
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges(); component.ngOnChanges();
fixture.whenStable().then(() => { expect(component.internalFileName).toEqual('blob file display name');
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('blob file display name');
done();
});
}); });
it('should show uknownn name if displayName is NOT set and blobFile is set', (done) => { it('should show uknownn name if displayName is NOT set and blobFile is set', (done) => {