mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Fix thumbnail-related document-list tests
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
|
import { MinimalNodeEntity } from '../models/document-library.model';
|
||||||
import {AlfrescoService} from '../../src/services/alfresco.service';
|
import {AlfrescoService} from '../../src/services/alfresco.service';
|
||||||
import {
|
import {
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
@@ -41,4 +42,8 @@ export class AlfrescoServiceMock extends AlfrescoService {
|
|||||||
observer.complete();
|
observer.complete();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDocumentThumbnailUrl(folder: MinimalNodeEntity) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -100,20 +100,34 @@ describe('DocumentList', () => {
|
|||||||
expect(documentList.folder).toBe(folder);
|
expect(documentList.folder).toBe(folder);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get content url', () => {
|
it('should return thumbnail url for a file when thumbnails turned on', () => {
|
||||||
let url = 'URL';
|
let url = 'URL';
|
||||||
spyOn(alfrescoServiceMock, 'getContentUrl').and.returnValue(url);
|
spyOn(alfrescoServiceMock, 'getDocumentThumbnailUrl').and.returnValue(url);
|
||||||
|
|
||||||
let result = documentList.getContentUrl(null);
|
let node = new MinimalNodeEntity();
|
||||||
|
node.entry = new MinimalNodeEntryEntity();
|
||||||
|
node.entry.isFile = true;
|
||||||
|
documentList.thumbnails = true;
|
||||||
|
let result = documentList.getThumbnailUrl(node);
|
||||||
|
|
||||||
expect(result).toBe(url);
|
expect(result).toBe(url);
|
||||||
expect(alfrescoServiceMock.getContentUrl).toHaveBeenCalled();
|
expect(alfrescoServiceMock.getDocumentThumbnailUrl).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return no content url without service', () => {
|
it('should return a null thumbnail url for a null item', () => {
|
||||||
|
let url = 'URL';
|
||||||
|
spyOn(alfrescoServiceMock, 'getDocumentThumbnailUrl').and.returnValue(url);
|
||||||
|
|
||||||
|
let result = documentList.getThumbnailUrl(null);
|
||||||
|
|
||||||
|
expect(result).toBeNull();
|
||||||
|
expect(alfrescoServiceMock.getDocumentThumbnailUrl).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return no thumbnail url without service', () => {
|
||||||
let list = new DocumentList(null);
|
let list = new DocumentList(null);
|
||||||
let node = new MinimalNodeEntity();
|
let node = new MinimalNodeEntity();
|
||||||
expect(list.getContentUrl(node)).toBeNull();
|
expect(list.getThumbnailUrl(node)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should execute action with node', () => {
|
it('should execute action with node', () => {
|
||||||
|
@@ -298,18 +298,6 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets content URL for the given node.
|
|
||||||
* @param node Node to get URL for.
|
|
||||||
* @returns {string} URL address.
|
|
||||||
*/
|
|
||||||
getContentUrl(node: MinimalNodeEntity): string {
|
|
||||||
if (this._alfrescoService) {
|
|
||||||
return this._alfrescoService.getContentUrl(node);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets thumbnail URL for the given node.
|
* Gets thumbnail URL for the given node.
|
||||||
* @param node Node to get URL for.
|
* @param node Node to get URL for.
|
||||||
|
Reference in New Issue
Block a user