fix test and coverage Angular2 Final release Form component #749

This commit is contained in:
Eugenio Romano
2016-10-07 12:22:35 +01:00
parent 08fccc84a3
commit 9fc6a0b85e
7 changed files with 149 additions and 144 deletions

View File

@@ -24,7 +24,7 @@ import { EcmModelService } from './src/services/ecm-model.service';
import { NodeService } from './src/services/node.service';
import { WidgetVisibilityService } from './src/services/widget-visibility.service';
import { ActivitiAlfrescoContentService } from './src/services/activiti-alfresco.service';
import { HttpModule } from '@angular/http';
import { WIDGET_DIRECTIVES } from './src/components/widgets/index';
export * from './src/components/activiti-form.component';
@@ -48,7 +48,8 @@ export const ACTIVITI_FORM_PROVIDERS: any[] = [
@NgModule({
imports: [
CoreModule
CoreModule,
HttpModule
],
declarations: [
...ACTIVITI_FORM_DIRECTIVES

View File

@@ -4,7 +4,7 @@
"version": "0.3.3",
"author": "Alfresco Software, Ltd.",
"scripts": {
"clean": "rimraf dist node_modules",
"clean": "npm install rimraf && rimraf dist node_modules typings",
"build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && license-check",
"build:w": "npm run tslint && rimraf dist && npm run watch-task",
"watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"license-check\"",

View File

@@ -15,43 +15,46 @@
* limitations under the License.
*/
/*
import { it, inject, describe, expect, beforeEach, beforeEachProviders, afterEach } from '@angular/core/testing';
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
import { NodeService } from './node.service';
import { TestBed } from '@angular/core/testing';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService
} from 'ng2-alfresco-core';
import { EcmModelService } from './ecm-model.service';
import { HTTP_PROVIDERS } from '@angular/http';
import { FormModel } from '../components/widgets/core/form.model';
import { Observable } from 'rxjs/Rx';
import { FormModel } from '../components/widgets/core/form.model';
import { HttpModule } from '@angular/http';
declare let jasmine: any;
describe('EcmModelService', () => {
let ecmModelService: EcmModelService;
let service;
beforeEachProviders(() => {
return [
AlfrescoAuthenticationService,
AlfrescoSettingsService,
NodeService,
EcmModelService,
HTTP_PROVIDERS,
AlfrescoApiService
];
beforeAll(() => {
TestBed.configureTestingModule({
imports: [HttpModule],
providers: [
AlfrescoSettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
EcmModelService
]
});
service = TestBed.get(EcmModelService);
});
beforeEach(inject([EcmModelService], (service: EcmModelService) => {
beforeEach(() => {
jasmine.Ajax.install();
ecmModelService = service;
}));
});
afterEach(() => {
jasmine.Ajax.uninstall();
});
it('Should fetch ECM models', (done) => {
ecmModelService.getEcmModels().subscribe(result => {
service.getEcmModels().subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('alfresco/versions/1/cmm')).toBeTruthy();
done();
});
@@ -67,9 +70,8 @@ describe('EcmModelService', () => {
let modelName = 'modelTest';
ecmModelService.getEcmType(modelName).subscribe(result => {
service.getEcmType(modelName).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + modelName + '/types')).toBeTruthy();
done();
});
@@ -84,11 +86,11 @@ describe('EcmModelService', () => {
let typeName = 'typeTest';
ecmModelService.createEcmType(typeName, EcmModelService.MODEL_NAME, EcmModelService.TYPE_MODEL).subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + EcmModelService.MODEL_NAME + '/types')).toBeTruthy();
service.createEcmType(typeName, service.MODEL_NAME, service.TYPE_MODEL).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + service.MODEL_NAME + '/types')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).name).toEqual(typeName);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).title).toEqual(typeName);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).parentName).toEqual(EcmModelService.TYPE_MODEL);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).parentName).toEqual(service.TYPE_MODEL);
done();
});
@@ -104,11 +106,11 @@ describe('EcmModelService', () => {
let typeName = 'typeTest:testName@#$*!';
let cleanName = 'testName';
ecmModelService.createEcmType(typeName, EcmModelService.MODEL_NAME, EcmModelService.TYPE_MODEL).subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + EcmModelService.MODEL_NAME + '/types')).toBeTruthy();
service.createEcmType(typeName, service.MODEL_NAME, service.TYPE_MODEL).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + service.MODEL_NAME + '/types')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).name).toEqual(cleanName);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).title).toEqual(typeName);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).parentName).toEqual(EcmModelService.TYPE_MODEL);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).parentName).toEqual(service.TYPE_MODEL);
done();
});
@@ -129,8 +131,8 @@ describe('EcmModelService', () => {
}
};
ecmModelService.addPropertyToAType(EcmModelService.MODEL_NAME, typeName, formFields).subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('1/cmm/' + EcmModelService.MODEL_NAME + '/types/' + typeName + '?select=props')).toBeTruthy();
service.addPropertyToAType(service.MODEL_NAME, typeName, formFields).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('1/cmm/' + service.MODEL_NAME + '/types/' + typeName + '?select=props')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).name).toEqual(typeName);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).properties).toEqual([{
name: 'test',
@@ -170,8 +172,8 @@ describe('EcmModelService', () => {
}
};
ecmModelService.addPropertyToAType(EcmModelService.MODEL_NAME, typeName, formFields).subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('1/cmm/' + EcmModelService.MODEL_NAME + '/types/' + cleanName + '?select=props')).toBeTruthy();
service.addPropertyToAType(service.MODEL_NAME, typeName, formFields).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('1/cmm/' + service.MODEL_NAME + '/types/' + cleanName + '?select=props')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).name).toEqual(cleanName);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).properties).toEqual([{
name: 'test',
@@ -202,7 +204,7 @@ describe('EcmModelService', () => {
it('Should create ECM model', (done) => {
ecmModelService.createEcmModel(EcmModelService.MODEL_NAME, EcmModelService.MODEL_NAMESPACE).subscribe(result => {
service.createEcmModel(service.MODEL_NAME, service.MODEL_NAMESPACE).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('alfresco/versions/1/cmm')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).status).toEqual('DRAFT');
done();
@@ -217,8 +219,8 @@ describe('EcmModelService', () => {
it('Should activate ECM model', (done) => {
ecmModelService.activeEcmModel(EcmModelService.MODEL_NAME).subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('alfresco/versions/1/cmm/' + EcmModelService.MODEL_NAME + '?select=status')).toBeTruthy();
service.activeEcmModel(service.MODEL_NAME).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('alfresco/versions/1/cmm/' + service.MODEL_NAME + '?select=status')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).status).toEqual('ACTIVE');
done();
});
@@ -231,113 +233,112 @@ describe('EcmModelService', () => {
});
it('Should create an ECM type with properties', (done) => {
spyOn(ecmModelService, 'createEcmType').and.callFake(() => {
spyOn(service, 'createEcmType').and.callFake(() => {
return Observable.create(observer => {
observer.next();
observer.complete();
});
});
spyOn(ecmModelService, 'addPropertyToAType').and.callFake(() => {
spyOn(service, 'addPropertyToAType').and.callFake(() => {
return Observable.create(observer => {
observer.next();
observer.complete();
});
});
ecmModelService.createEcmTypeWithProperties('nameType', new FormModel()).subscribe(result => {
expect(ecmModelService.createEcmType).toHaveBeenCalled();
expect(ecmModelService.addPropertyToAType).toHaveBeenCalled();
service.createEcmTypeWithProperties('nameType', new FormModel()).subscribe(() => {
expect(service.createEcmType).toHaveBeenCalled();
expect(service.addPropertyToAType).toHaveBeenCalled();
done();
});
});
it('Should return the already existing type', (done) => {
spyOn(ecmModelService, 'searchEcmType').and.callFake(() => {
spyOn(service, 'searchEcmType').and.callFake(() => {
return Observable.create(observer => {
observer.next({test: 'I-EXIST'});
observer.complete();
});
});
spyOn(ecmModelService, 'createEcmTypeWithProperties').and.callFake(() => {
spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => {
return Observable.create(observer => {
observer.next();
observer.complete();
});
});
ecmModelService.saveFomType('nameType', new FormModel()).subscribe(result => {
expect(ecmModelService.searchEcmType).toHaveBeenCalled();
expect(ecmModelService.createEcmTypeWithProperties).not.toHaveBeenCalled();
service.saveFomType('nameType', new FormModel()).subscribe(() => {
expect(service.searchEcmType).toHaveBeenCalled();
expect(service.createEcmTypeWithProperties).not.toHaveBeenCalled();
done();
});
});
it('Should create an ECM type with properties if the ecm Type is not defined already', (done) => {
spyOn(ecmModelService, 'searchEcmType').and.callFake(() => {
spyOn(service, 'searchEcmType').and.callFake(() => {
return Observable.create(observer => {
observer.next();
observer.complete();
});
});
spyOn(ecmModelService, 'createEcmTypeWithProperties').and.callFake(() => {
spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => {
return Observable.create(observer => {
observer.next();
observer.complete();
});
});
ecmModelService.saveFomType('nameType', new FormModel()).subscribe(result => {
expect(ecmModelService.searchEcmType).toHaveBeenCalled();
expect(ecmModelService.createEcmTypeWithProperties).toHaveBeenCalled();
service.saveFomType('nameType', new FormModel()).subscribe(() => {
expect(service.searchEcmType).toHaveBeenCalled();
expect(service.createEcmTypeWithProperties).toHaveBeenCalled();
done();
});
});
it('Should create an ECM model for the activiti if not defined already', (done) => {
spyOn(ecmModelService, 'seachActivitiEcmModel').and.callFake(() => {
spyOn(service, 'searchActivitiEcmModel').and.callFake(() => {
return Observable.create(observer => {
observer.next();
observer.complete();
});
});
spyOn(ecmModelService, 'createActivitiEcmModel').and.callFake(() => {
spyOn(service, 'createActivitiEcmModel').and.callFake(() => {
return Observable.create(observer => {
observer.next();
observer.complete();
});
});
ecmModelService.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(result => {
expect(ecmModelService.seachActivitiEcmModel).toHaveBeenCalled();
expect(ecmModelService.createActivitiEcmModel).toHaveBeenCalled();
service.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(() => {
expect(service.searchActivitiEcmModel).toHaveBeenCalled();
expect(service.createActivitiEcmModel).toHaveBeenCalled();
done();
});
});
it('If a model for the activiti is already define has to save the new type', (done) => {
spyOn(ecmModelService, 'seachActivitiEcmModel').and.callFake(() => {
spyOn(service, 'searchActivitiEcmModel').and.callFake(() => {
return Observable.create(observer => {
observer.next({test: 'I-EXIST'});
observer.complete();
});
});
spyOn(ecmModelService, 'saveFomType').and.callFake(() => {
spyOn(service, 'saveFomType').and.callFake(() => {
return Observable.create(observer => {
observer.next();
observer.complete();
});
});
ecmModelService.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(result => {
expect(ecmModelService.seachActivitiEcmModel).toHaveBeenCalled();
expect(ecmModelService.saveFomType).toHaveBeenCalled();
service.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(() => {
expect(service.searchActivitiEcmModel).toHaveBeenCalled();
expect(service.saveFomType).toHaveBeenCalled();
done();
});
});
});
*/

View File

@@ -20,7 +20,6 @@ import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfr
import { Observable } from 'rxjs/Rx';
import { Response, Http, Headers, RequestOptions } from '@angular/http';
import { FormModel } from '../components/widgets/core/form.model';
import { NodeService } from './node.service';
@Injectable()
export class EcmModelService {
@@ -31,13 +30,12 @@ export class EcmModelService {
constructor(private authService: AlfrescoAuthenticationService,
private http: Http,
public alfrescoSettingsService: AlfrescoSettingsService,
private nodeService: NodeService) {
public alfrescoSettingsService: AlfrescoSettingsService) {
}
public createEcmTypeForActivitiForm(formName: string, form: FormModel): Observable<any> {
return Observable.create(observer => {
this.seachActivitiEcmModel().subscribe(
this.searchActivitiEcmModel().subscribe(
model => {
if (!model) {
this.createActivitiEcmModel(formName, form).subscribe(typeForm => {
@@ -57,7 +55,7 @@ export class EcmModelService {
}
seachActivitiEcmModel() {
searchActivitiEcmModel() {
return this.getEcmModels().map(function (ecmModels: any) {
return ecmModels.list.entries.find(model => model.entry.name === EcmModelService.MODEL_NAME);
});

View File

@@ -15,37 +15,40 @@
* limitations under the License.
*/
/*
import { it, inject, describe, expect, beforeEach, beforeEachProviders, afterEach } from '@angular/core/testing';
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
import { HTTP_PROVIDERS, Response, ResponseOptions } from '@angular/http';
import { TestBed } from '@angular/core/testing';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService
} from 'ng2-alfresco-core';
import { FormService } from './form.service';
import { EcmModelService } from './ecm-model.service';
import { NodeService } from './node.service';
import { FormDefinitionModel } from '../models/form-definition.model';
import { HttpModule, Response, ResponseOptions } from '@angular/http';
declare let jasmine: any;
describe('FormService', () => {
let responseBody: any, formService: FormService;
let responseBody: any, service: FormService;
beforeEachProviders(() => {
return [
FormService,
AlfrescoSettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
EcmModelService,
HTTP_PROVIDERS,
NodeService
];
beforeAll(() => {
TestBed.configureTestingModule({
imports: [HttpModule],
providers: [
AlfrescoAuthenticationService,
AlfrescoSettingsService,
EcmModelService,
AlfrescoApiService,
FormService
]
});
service = TestBed.get(FormService);
});
beforeEach(inject([FormService], (service: FormService) => {
beforeEach(() => {
jasmine.Ajax.install();
formService = service;
}));
});
afterEach(() => {
jasmine.Ajax.uninstall();
@@ -59,7 +62,7 @@ describe('FormService', () => {
]
};
formService.getProcessDefinitions().subscribe(result => {
service.getProcessDefinitions().subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/process-definitions')).toBeTruthy();
expect(result).toEqual(JSON.parse(jasmine.Ajax.requests.mostRecent().response).data);
done();
@@ -80,7 +83,7 @@ describe('FormService', () => {
]
};
formService.getTasks().subscribe(result => {
service.getTasks().subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/tasks/query')).toBeTruthy();
expect(result).toEqual(JSON.parse(jasmine.Ajax.requests.mostRecent().response).data);
done();
@@ -98,7 +101,7 @@ describe('FormService', () => {
id: '1'
};
formService.getTask('1').subscribe(result => {
service.getTask('1').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/tasks/1')).toBeTruthy();
expect(result.id).toEqual(responseBody.id);
done();
@@ -117,7 +120,7 @@ describe('FormService', () => {
field2: 'two'
};
formService.saveTaskForm('1', values).subscribe(() => {
service.saveTaskForm('1', values).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/task-forms/1/save-form')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).values.field1).toEqual(values.field1);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).values.field2).toEqual(values.field2);
@@ -137,7 +140,7 @@ describe('FormService', () => {
field2: 'two'
};
formService.completeTaskForm('1', values).subscribe(() => {
service.completeTaskForm('1', values).subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/task-forms/1')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).values.field1).toEqual(values.field1);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).values.field2).toEqual(values.field2);
@@ -157,7 +160,7 @@ describe('FormService', () => {
field2: 'two'
};
formService.completeTaskForm('1', values, 'custom').subscribe(() => {
service.completeTaskForm('1', values, 'custom').subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/task-forms/1')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).values.field2).toEqual(values.field2);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).outcome).toEqual('custom');
@@ -175,7 +178,7 @@ describe('FormService', () => {
it('should get task form by id', (done) => {
responseBody = {id: 1};
formService.getTaskForm('1').subscribe(result => {
service.getTaskForm('1').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/task-forms/1')).toBeTruthy();
expect(result.id).toEqual(responseBody.id);
done();
@@ -191,7 +194,7 @@ describe('FormService', () => {
it('should get form definition by id', (done) => {
responseBody = {id: 1};
formService.getFormDefinitionById('1').subscribe(result => {
service.getFormDefinitionById('1').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/form-models/1')).toBeTruthy();
expect(result.id).toEqual(responseBody.id);
done();
@@ -213,7 +216,7 @@ describe('FormService', () => {
]
};
formService.getFormDefinitionByName(formName).subscribe(result => {
service.getFormDefinitionByName(formName).subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith(`models?filter=myReusableForms&filterText=${formName}&modelType=2`)).toBeTruthy();
expect(result).toEqual(formId);
done();
@@ -228,34 +231,34 @@ describe('FormService', () => {
it('should not get form id from response', () => {
let response = new Response(new ResponseOptions({body: null}));
expect(formService.getFormId(response)).toBeNull();
expect(service.getFormId(response)).toBeNull();
response = new Response(new ResponseOptions({body: {}}));
expect(formService.getFormId(response)).toBeNull();
expect(service.getFormId(response)).toBeNull();
response = new Response(new ResponseOptions({body: {data: null}}));
expect(formService.getFormId(response)).toBeNull();
expect(service.getFormId(response)).toBeNull();
response = new Response(new ResponseOptions({body: {data: []}}));
expect(formService.getFormId(response)).toBeNull();
expect(service.getFormId(response)).toBeNull();
expect(formService.getFormId(null)).toBeNull();
expect(service.getFormId(null)).toBeNull();
});
it('should fallback to empty json array', () => {
expect(formService.toJsonArray(null)).toEqual([]);
expect(service.toJsonArray(null)).toEqual([]);
let response = new Response(new ResponseOptions({body: {}}));
expect(formService.toJsonArray(response)).toEqual([]);
expect(service.toJsonArray(response)).toEqual([]);
response = new Response(new ResponseOptions({body: {data: null}}));
expect(formService.toJsonArray(response)).toEqual([]);
expect(service.toJsonArray(response)).toEqual([]);
});
it('should handle error with generic message', () => {
spyOn(console, 'error').and.stub();
formService.handleError(null);
service.handleError(null);
expect(console.error).toHaveBeenCalledWith(FormService.UNKNOWN_ERROR_MESSAGE);
});
@@ -263,14 +266,14 @@ describe('FormService', () => {
spyOn(console, 'error').and.stub();
const message = '<error>';
formService.handleError({message: message});
service.handleError({message: message});
expect(console.error).toHaveBeenCalledWith(message);
});
it('should handle error with detailed message', () => {
spyOn(console, 'error').and.stub();
formService.handleError({
service.handleError({
status: '400',
statusText: 'Bad request'
});
@@ -279,14 +282,14 @@ describe('FormService', () => {
it('should handle error with generic message', () => {
spyOn(console, 'error').and.stub();
formService.handleError({});
service.handleError({});
expect(console.error).toHaveBeenCalledWith(FormService.GENERIC_ERROR_MESSAGE);
});
it('should get all the forms with modelType=2', (done) => {
responseBody = {};
formService.getForms().subscribe(result => {
service.getForms().subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('models?modelType=2')).toBeTruthy();
expect(result).toEqual(responseBody);
done();
@@ -302,7 +305,7 @@ describe('FormService', () => {
it('should search for Form with modelType=2', (done) => {
responseBody = {data: [{id: 1, name: 'findme'}, {id: 2, name: 'testform'}]};
formService.searchFrom('findme').subscribe(result => {
service.searchFrom('findme').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('models?modelType=2')).toBeTruthy();
expect(result.name).toEqual('findme');
expect(result.id).toEqual(1);
@@ -319,7 +322,7 @@ describe('FormService', () => {
it('should create a Form with modelType=2', (done) => {
responseBody = {id: 1, modelType: 'test'};
formService.createForm('testName').subscribe(result => {
service.createForm('testName').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/models')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).modelType).toEqual(2);
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).name).toEqual('testName');
@@ -341,7 +344,7 @@ describe('FormService', () => {
let data = [{name: 'name'}, {name: 'email'}];
let formDefinitionModel = new FormDefinitionModel(formId, name, 'testUserName', '2016-09-05T14:41:19.049Z', data);
formService.addFieldsToAForm(formId, formDefinitionModel).subscribe(result => {
service.addFieldsToAForm(formId, formDefinitionModel).subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('/form-models/' + formId)).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).formRepresentation.name).toEqual(name);
done();
@@ -368,7 +371,7 @@ describe('FormService', () => {
stubAddFieldsToAForm();
formService.createFormFromANode(nameForm).subscribe(result => {
service.createFormFromANode(nameForm).subscribe(result => {
expect(result.id).toEqual(formId);
done();
});
@@ -417,4 +420,3 @@ describe('FormService', () => {
}
});
});
*/

View File

@@ -15,32 +15,40 @@
* limitations under the License.
*/
/*
import { it, inject, describe, expect, beforeEach, beforeEachProviders, afterEach } from '@angular/core/testing';
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
import { TestBed } from '@angular/core/testing';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService
} from 'ng2-alfresco-core';
import { NodeService } from './node.service';
import { NodeMetadata } from '../models/node-metadata.model';
import { HttpModule } from '@angular/http';
import { EcmModelService } from './ecm-model.service';
declare let jasmine: any;
describe('NodeService', () => {
let nodeService: NodeService;
let service: NodeService;
beforeEachProviders(() => {
return [
AlfrescoAuthenticationService,
AlfrescoSettingsService,
NodeService,
AlfrescoApiService
];
beforeAll(() => {
TestBed.configureTestingModule({
imports: [HttpModule],
providers: [
AlfrescoAuthenticationService,
AlfrescoSettingsService,
NodeService,
AlfrescoApiService,
EcmModelService
]
});
service = TestBed.get(NodeService);
});
beforeEach(inject([NodeService], (service: NodeService) => {
beforeEach(() => {
jasmine.Ajax.install();
nodeService = service;
}));
});
afterEach(() => {
jasmine.Ajax.uninstall();
@@ -58,7 +66,7 @@ describe('NodeService', () => {
}
};
nodeService.getNodeMetadata('-nodeid-').subscribe(result => {
service.getNodeMetadata('-nodeid-').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('nodes/-nodeid-')).toBeTruthy();
let node = new NodeMetadata({
test: 'test',
@@ -87,7 +95,7 @@ describe('NodeService', () => {
}
};
nodeService.getNodeMetadata('-nodeid-').subscribe(result => {
service.getNodeMetadata('-nodeid-').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('nodes/-nodeid-')).toBeTruthy();
let node = new NodeMetadata({
test: 'test',
@@ -116,7 +124,7 @@ describe('NodeService', () => {
isFolder: true
};
nodeService.createNodeMetadata('typeTest', EcmModelService.MODEL_NAMESPACE, data, '/Sites/swsdp/documentLibrary', 'testNode').subscribe(result => {
service.createNodeMetadata('typeTest', EcmModelService.MODEL_NAMESPACE, data, '/Sites/swsdp/documentLibrary', 'testNode').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('-root-/children')).toBeTruthy();
expect(result).toEqual(responseBody);
done();
@@ -135,7 +143,7 @@ describe('NodeService', () => {
testdata: 'testdata'
};
nodeService.createNodeMetadata('typeTest', EcmModelService.MODEL_NAMESPACE, data, '/Sites/swsdp/documentLibrary').subscribe(result => {
service.createNodeMetadata('typeTest', EcmModelService.MODEL_NAMESPACE, data, '/Sites/swsdp/documentLibrary').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('-root-/children')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).properties[EcmModelService.MODEL_NAMESPACE + ':test']).toBeDefined();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).properties[EcmModelService.MODEL_NAMESPACE + ':testdata']).toBeDefined();
@@ -156,7 +164,7 @@ describe('NodeService', () => {
};
nodeService.createNodeMetadata('typeTest', EcmModelService.MODEL_NAMESPACE, data, '/Sites/swsdp/documentLibrary').subscribe(result => {
service.createNodeMetadata('typeTest', EcmModelService.MODEL_NAMESPACE, data, '/Sites/swsdp/documentLibrary').subscribe(result => {
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('-root-/children')).toBeTruthy();
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).name).toBeDefined();
done();
@@ -170,4 +178,4 @@ describe('NodeService', () => {
});
});
*/

View File

@@ -8,19 +8,14 @@
"sourceMap": true,
"removeComments": true,
"declaration": true,
"noLib": false,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitAny": false,
"noImplicitReturns": false,
"noImplicitUseStrict": false,
"noFallthroughCasesInSwitch": true,
"outDir": "dist",
"types": ["core-js", "jasmine", "node"]
"outDir": "dist"
},
"exclude": [
"demo",
"dist",
"node_modules",
"typings/main",
"typings/main.d.ts",
"dist"
]
}