Fix thumbnail-related document-list tests

This commit is contained in:
Will Abson
2016-06-10 10:51:04 +01:00
parent 91b93464e8
commit a9a84026e0
3 changed files with 25 additions and 18 deletions

View File

@@ -16,6 +16,7 @@
*/
import {Observable} from 'rxjs/Observable';
import { MinimalNodeEntity } from '../models/document-library.model';
import {AlfrescoService} from '../../src/services/alfresco.service';
import {
AlfrescoSettingsService,
@@ -41,4 +42,8 @@ export class AlfrescoServiceMock extends AlfrescoService {
observer.complete();
});
}
getDocumentThumbnailUrl(folder: MinimalNodeEntity) {
return '';
}
}

View File

@@ -100,20 +100,34 @@ describe('DocumentList', () => {
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';
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(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 node = new MinimalNodeEntity();
expect(list.getContentUrl(node)).toBeNull();
expect(list.getThumbnailUrl(node)).toBeNull();
});
it('should execute action with node', () => {

View File

@@ -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.
* @param node Node to get URL for.