From 2e77347e49b5c2cbca4226f576c2786f9ba2c6c6 Mon Sep 17 00:00:00 2001 From: Yasa-Nataliya Date: Wed, 22 Nov 2023 18:55:41 +0530 Subject: [PATCH] [ACS-5600]modified the test cases --- .../alfresco-viewer.component.spec.ts | 38 +++++++++++++++---- .../components/viewer.component.spec.ts | 18 ++++++++- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts index 960866d87ec..be0f4142eda 100644 --- a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts +++ b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts @@ -477,16 +477,38 @@ describe('AlfrescoViewerComponent', () => { }); describe('originalMimeType', () => { - - it('should set originalMimeType based on nodeData content', () => { - component.originalMimeType= 'application/pdf'; - const nodeData = { + it('should set originalMimeType based on nodeData content', async () => { + const defaultNode: Node = { + id: '123', + name: 'Mock Node', + nodeType: 'cm:content', + isFolder: false, + isFile: true, + modifiedAt: new Date(), + modifiedByUser: { id: 'user123', displayName: 'John Doe' }, + createdAt: new Date(), + createdByUser: { id: 'user456', displayName: 'Jane Doe' }, + isLocked: false, + parentId: 'parent123', + isLink: false, + isFavorite: false, content: { - mimeType: 'application/pdf' - } + mimeType: 'application/msWord', + mimeTypeName: 'Doc Document', + sizeInBytes: 0 + }, + aspectNames: ['cm:auditable', 'cm:versionable'], + properties: { customProperty: 'customValue' }, + allowableOperations: ['update', 'delete', 'create-child'], + path: { name: '/Sites/Document Library/Mock Node', isComplete: true }, + permissions: {}, + definition: {} }; - component.ngOnInit(); - expect(component.originalMimeType).toEqual(nodeData.content.mimeType); + + spyOn(component['viewUtilService'], 'getViewerType').and.returnValue('unknown'); + + await component['setUpNodeFile'](defaultNode); + expect(component.originalMimeType).toEqual(defaultNode?.content?.mimeType); }); }); diff --git a/lib/core/src/lib/viewer/components/viewer.component.spec.ts b/lib/core/src/lib/viewer/components/viewer.component.spec.ts index 6d4fa619431..032e99ab831 100644 --- a/lib/core/src/lib/viewer/components/viewer.component.spec.ts +++ b/lib/core/src/lib/viewer/components/viewer.component.spec.ts @@ -120,14 +120,28 @@ describe('ViewerComponent', () => { it('should set alt attribute to originalMimeType when originalMimeType is provided', () => { component.originalMimeType = 'image/png'; fixture.detectChanges(); - const altAttribute = fixture.nativeElement.querySelector('.adf-viewer__mimeicon').getAttribute('alt'); + const altAttribute: string = fixture.nativeElement.querySelector('.adf-viewer__mimeicon').getAttribute('alt'); expect(altAttribute).toBe('image/png'); }); it('should set src attribute based on originalMimeType when originalMimeType is provided', () => { component.originalMimeType = 'image'; fixture.detectChanges(); - const srcAttribute = fixture.nativeElement.querySelector('.adf-viewer__mimeicon').getAttribute('src'); + const srcAttribute: string = fixture.nativeElement.querySelector('.adf-viewer__mimeicon').getAttribute('src'); + expect(srcAttribute).toContain('image'); + }); + + it('should set alt attribute to mimeType when originalMimeType is not provided', () => { + component.mimeType = 'application/pdf'; + fixture.detectChanges(); + const altAttribute: string = fixture.nativeElement.querySelector('.adf-viewer__mimeicon').getAttribute('alt'); + expect(altAttribute).toBe('application/pdf'); + }); + + it('should set src attribute based on mimeType when originalMimeType is not provided', () => { + component.mimeType = 'image'; + fixture.detectChanges(); + const srcAttribute: string = fixture.nativeElement.querySelector('.adf-viewer__mimeicon').getAttribute('src'); expect(srcAttribute).toContain('image'); }); });