renditions available methods

This commit is contained in:
Eugenio Romano
2016-09-07 14:27:12 +02:00
parent 8c76aed11d
commit 0c60ff168d
3 changed files with 60 additions and 5 deletions

View File

@@ -28,6 +28,14 @@ describe('RenditionsService', () => {
let service: any;
let fakeRedition = {
'entry': {
'id': 'pdf',
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
'status': 'NOT_CREATED'
}
};
let fakeReditionsList = {
'list': {
'pagination': {
'count': 6,
@@ -95,12 +103,41 @@ describe('RenditionsService', () => {
jasmine.Ajax.uninstall();
});
it('Get redition list service should call the server with the ID passed', (done) => {
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');
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeReditionsList)
});
});
it('Get redition service should call the server with the ID passed', (done) => {
service.getRendition('fake-node-id', 'pdf').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/pdf');
expect(res.entry.status).toBe('NOT_CREATED');
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeRedition)
});
});
it('isRenditionsAvailable service should call the server with the ID passed and return false if is not created', (done) => {
service.isRenditionAvailable('fake-node-id', 'pdf').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/pdf');
expect(res).toBe(false);
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
@@ -131,7 +168,7 @@ describe('RenditionsService', () => {
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 403,
contentType: 'application/json',
responseText: JSON.stringify(fakeRedition)
responseText: 'error'
});
});
});