Skip to content

Commit

Permalink
[ACS-5600]modified the test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Yasa-Nataliya committed Nov 22, 2023
1 parent c6fca56 commit 9310bb1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
18 changes: 16 additions & 2 deletions lib/core/src/lib/viewer/components/viewer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Expand Down

0 comments on commit 9310bb1

Please sign in to comment.