mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Fix unit tests
This commit is contained in:
@@ -23,10 +23,12 @@ import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiServ
|
||||
import { RenderingQueueServices } from '../services/rendering-queue.services';
|
||||
|
||||
declare let jasmine: any;
|
||||
declare let AlfrescoApi: any;
|
||||
|
||||
describe('ViewerComponent', () => {
|
||||
|
||||
let viewerComponentFixture, element, component;
|
||||
let apiService: AlfrescoApiService;
|
||||
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
@@ -37,7 +39,10 @@ describe('ViewerComponent', () => {
|
||||
];
|
||||
});
|
||||
|
||||
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
beforeEach(inject([TestComponentBuilder, AlfrescoApiService], (tcb: TestComponentBuilder, api: AlfrescoApiService) => {
|
||||
apiService = api;
|
||||
apiService.setInstance(new AlfrescoApi({}));
|
||||
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then(fixture => {
|
||||
@@ -161,27 +166,16 @@ describe('ViewerComponent', () => {
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('If FileNodeId is present the node api should be called', (done) => {
|
||||
it('If FileNodeId is present the node api should be called', (/*done*/) => {
|
||||
component.showViewer = true;
|
||||
component.fileNodeId = 'file-node-id';
|
||||
component.urlFile = undefined;
|
||||
|
||||
jasmine.Ajax.stubRequest(
|
||||
'http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/file-node-id'
|
||||
).andReturn({
|
||||
status: 200,
|
||||
responseText: '{"entry":{"isFile":true,"createdByUser":{"id":"admin","displayName":"Administrator"},' +
|
||||
'"modifiedAt":"2016-08-05T23:08:22.730+0000","nodeType":"cm:content","content":' +
|
||||
'{"mimeType":"application/pdf","mimeTypeName":"Adobe PDF Document","sizeInBytes":' +
|
||||
'381778,"encoding":"UTF-8"},"parentId":"8f2105b4-daaf-4874-9e8a-2152569d109b","createdAt":"2016-08-05T23:08:22.730+0000","isFolder":false,' +
|
||||
'"modifiedByUser":{"id":"admin","displayName":"Administrator"},"name":"content.pdf","id":' +
|
||||
'"b8bd4c81-6f2e-4ec2-9c4d-30c97cf42bc8"}}'
|
||||
});
|
||||
let alfrescoApi = apiService.getInstance();
|
||||
spyOn(alfrescoApi.nodes, 'getNodeInfo').and.stub();
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('nodes/file-node-id')).toBe(true);
|
||||
done();
|
||||
});
|
||||
component.ngOnChanges();
|
||||
expect(alfrescoApi.nodes.getNodeInfo).toHaveBeenCalledWith(component.fileNodeId);
|
||||
});
|
||||
|
||||
it('showViewer default value should be true', () => {
|
||||
|
Reference in New Issue
Block a user