mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
move renditions service in the core
This commit is contained in:
@@ -22,3 +22,4 @@ export * from './AlfrescoTranslation.service';
|
|||||||
export * from './AlfrescoPipeTranslate.service';
|
export * from './AlfrescoPipeTranslate.service';
|
||||||
export * from './AlfrescoAuthentication.service';
|
export * from './AlfrescoAuthentication.service';
|
||||||
export * from './AlfrescoContent.service';
|
export * from './AlfrescoContent.service';
|
||||||
|
export * from './renditions.service';
|
||||||
|
@@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||||
import { RenditionsService } from './renditions.service';
|
import { RenditionsService } from './renditions.service';
|
||||||
import { AlfrescoSettingsService, AlfrescoApiService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
import { AlfrescoApiService } from './AlfrescoApi.service';
|
||||||
|
import { AlfrescoSettingsService } from './AlfrescoSettings.service';
|
||||||
|
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
declare let AlfrescoApi: any;
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
@@ -25,6 +27,55 @@ declare let jasmine: any;
|
|||||||
describe('RenditionsService', () => {
|
describe('RenditionsService', () => {
|
||||||
let service: any;
|
let service: any;
|
||||||
|
|
||||||
|
let fakeRedition = {
|
||||||
|
'list': {
|
||||||
|
'pagination': {
|
||||||
|
'count': 6,
|
||||||
|
'hasMoreItems': false,
|
||||||
|
'totalItems': 6,
|
||||||
|
'skipCount': 0,
|
||||||
|
'maxItems': 100
|
||||||
|
},
|
||||||
|
'entries': [{
|
||||||
|
'entry': {
|
||||||
|
'id': 'avatar',
|
||||||
|
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'avatar32',
|
||||||
|
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'doclib',
|
||||||
|
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'imgpreview',
|
||||||
|
'content': {'mimeType': 'image/jpeg', 'mimeTypeName': 'JPEG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'medium',
|
||||||
|
'content': {'mimeType': 'image/jpeg', 'mimeTypeName': 'JPEG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'pdf',
|
||||||
|
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
beforeEachProviders(() => {
|
beforeEachProviders(() => {
|
||||||
return [
|
return [
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
@@ -44,15 +95,16 @@ describe('RenditionsService', () => {
|
|||||||
jasmine.Ajax.uninstall();
|
jasmine.Ajax.uninstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Get redition service should call the server with the ID passed', (done) => {
|
it('Get redition list service should call the server with the ID passed', (done) => {
|
||||||
service.getRenditionsByNodeId('fake-node-id').subscribe((res) => {
|
service.getRenditionsListByNodeId('fake-node-id').subscribe((res) => {
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
'status': 200,
|
||||||
contentType: 'application/json'
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify(fakeRedition)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -64,13 +116,13 @@ describe('RenditionsService', () => {
|
|||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
'status': 200,
|
||||||
contentType: 'application/json'
|
contentType: 'application/json',
|
||||||
|
responseText: ''
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Get redition service should catch the error', (done) => {
|
it('Get redition service should catch the error', (done) => {
|
||||||
|
service.getRenditionsListByNodeId('fake-node-id').subscribe((res) => {
|
||||||
service.getRenditionsByNodeId('fake-node-id').subscribe((res) => {
|
|
||||||
}, (res) => {
|
}, (res) => {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@@ -78,7 +130,8 @@ describe('RenditionsService', () => {
|
|||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 403,
|
'status': 403,
|
||||||
contentType: 'application/json'
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify(fakeRedition)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import { AlfrescoApiService } from 'ng2-alfresco-core';
|
import { AlfrescoApiService } from './AlfrescoApi.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RenditionsService
|
* RenditionsService
|
||||||
@@ -31,7 +31,13 @@ export class RenditionsService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getRenditionsByNodeId(nodeId: string) {
|
isReditionsAvailable(nodeId: string, encoding: string) {
|
||||||
|
this.apiService.getInstance().core.renditionsApi.getRenditions(nodeId).then((res) => {
|
||||||
|
console.log('res' + res);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getRenditionsListByNodeId(nodeId: string) {
|
||||||
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.getRenditions(nodeId))
|
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.getRenditions(nodeId))
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
Reference in New Issue
Block a user