fix no content node display (#3351)

This commit is contained in:
Eugenio Romano
2018-05-21 16:44:16 +01:00
committed by Denys Vuika
parent 8fae47639c
commit e8cf6f6f38
2 changed files with 46 additions and 14 deletions

View File

@@ -41,7 +41,8 @@ import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
</adf-viewer>
`
})
class ViewerWithCustomToolbarComponent {}
class ViewerWithCustomToolbarComponent {
}
@Component({
selector: 'adf-viewer-container-toolbar-actions',
@@ -55,7 +56,8 @@ class ViewerWithCustomToolbarComponent {}
</adf-viewer>
`
})
class ViewerWithCustomToolbarActionsComponent {}
class ViewerWithCustomToolbarActionsComponent {
}
@Component({
selector: 'adf-viewer-container-sidebar',
@@ -67,7 +69,8 @@ class ViewerWithCustomToolbarActionsComponent {}
</adf-viewer>
`
})
class ViewerWithCustomSidebarComponent {}
class ViewerWithCustomSidebarComponent {
}
@Component({
selector: 'adf-viewer-container-open-with',
@@ -90,7 +93,8 @@ class ViewerWithCustomSidebarComponent {}
</adf-viewer>
`
})
class ViewerWithCustomOpenWithComponent {}
class ViewerWithCustomOpenWithComponent {
}
@Component({
selector: 'adf-viewer-container-more-actions',
@@ -113,7 +117,8 @@ class ViewerWithCustomOpenWithComponent {}
</adf-viewer>
`
})
class ViewerWithCustomMoreActionsComponent {}
class ViewerWithCustomMoreActionsComponent {
}
describe('ViewerComponent', () => {
@@ -135,11 +140,13 @@ describe('ViewerComponent', () => {
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{provide: RenditionsService, useValue: {
{
provide: RenditionsService, useValue: {
getRendition: () => {
return Observable.throw('throwed');
}
}},
}
},
RenderingQueueServices,
{ provide: Location, useClass: SpyLocation }
]
@@ -671,6 +678,28 @@ describe('ViewerComponent', () => {
expect(element.querySelector('adf-media-player')).not.toBeNull();
});
}));
it('should node without content show unkonwn', async(() => {
const displayName = 'the-name';
const nodeDetails = { name: displayName, id: '12' };
const contentUrl = '/content/url/path';
const alfrescoApiInstanceMock = {
nodes: { getNodeInfo: () => Promise.resolve(nodeDetails) },
content: { getContentUrl: () => contentUrl }
};
component.fileNodeId = '12';
component.urlFile = null;
component.displayName = null;
spyOn(alfrescoApiService, 'getInstance').and.returnValue(alfrescoApiInstanceMock);
component.ngOnChanges(null);
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('adf-viewer-unknown-format')).toBeDefined();
});
}));
});
describe('Events', () => {

View File

@@ -334,7 +334,10 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
}
private setUpNodeFile(data: MinimalNodeEntryEntity) {
if (data.content) {
this.mimeType = data.content.mimeType;
}
this.displayName = data.name;
this.urlFileContent = this.apiService.contentApi.getContentUrl(data.id);