mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
more tests
This commit is contained in:
@@ -32,8 +32,8 @@ describe('ActivitiFilters', () => {
|
|||||||
let filterList: ActivitiFilters;
|
let filterList: ActivitiFilters;
|
||||||
|
|
||||||
let fakeGlobalFilter = [];
|
let fakeGlobalFilter = [];
|
||||||
fakeGlobalFilter.push(new FilterModel('FakeInvolvedTasks', false, 'glyphicon-align-left', '', 'open', 'fake-involved'));
|
fakeGlobalFilter.push(new FilterModel('FakeInvolvedTasks', false, 'glyphicon-align-left', '', 'open', 'fake-involved'));
|
||||||
fakeGlobalFilter.push(new FilterModel('FakeMyTasks', false, 'glyphicon-align-left', '', 'open', 'fake-assignee'));
|
fakeGlobalFilter.push(new FilterModel('FakeMyTasks', false, 'glyphicon-align-left', '', 'open', 'fake-assignee'));
|
||||||
|
|
||||||
let fakeGlobalFilterPromise = new Promise(function (resolve, reject) {
|
let fakeGlobalFilterPromise = new Promise(function (resolve, reject) {
|
||||||
resolve(fakeGlobalFilter);
|
resolve(fakeGlobalFilter);
|
||||||
@@ -55,7 +55,7 @@ describe('ActivitiFilters', () => {
|
|||||||
it('should return the filter task list', (done) => {
|
it('should return the filter task list', (done) => {
|
||||||
spyOn(filterList.activiti, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
|
spyOn(filterList.activiti, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
|
||||||
|
|
||||||
filterList.onSuccess.subscribe( (res) => {
|
filterList.onSuccess.subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(filterList.filters).toBeDefined();
|
expect(filterList.filters).toBeDefined();
|
||||||
expect(filterList.filters.length).toEqual(2);
|
expect(filterList.filters.length).toEqual(2);
|
||||||
@@ -67,10 +67,31 @@ describe('ActivitiFilters', () => {
|
|||||||
filterList.ngOnInit();
|
filterList.ngOnInit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return the filter task list, filtered By Name', (done) => {
|
||||||
|
|
||||||
|
let fakeDeployedApplicationsPromise = new Promise(function (resolve, reject) {
|
||||||
|
resolve({});
|
||||||
|
});
|
||||||
|
|
||||||
|
spyOn(filterList.activiti, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeDeployedApplicationsPromise));
|
||||||
|
spyOn(filterList.activiti, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
|
||||||
|
|
||||||
|
filterList.appName = 'test';
|
||||||
|
|
||||||
|
filterList.onSuccess.subscribe((res) => {
|
||||||
|
let deployApp: any = filterList.activiti.getDeployedApplications;
|
||||||
|
expect(deployApp.calls.count()).toEqual(1);
|
||||||
|
expect(res).toBeDefined();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
filterList.ngOnInit();
|
||||||
|
});
|
||||||
|
|
||||||
it('should emit an error with a bad response', (done) => {
|
it('should emit an error with a bad response', (done) => {
|
||||||
spyOn(filterList.activiti, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
|
spyOn(filterList.activiti, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
|
||||||
|
|
||||||
filterList.onError.subscribe( (err) => {
|
filterList.onError.subscribe((err) => {
|
||||||
expect(err).toBeDefined();
|
expect(err).toBeDefined();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@@ -89,12 +89,12 @@ export class ActivitiFilters implements OnInit {
|
|||||||
if (this.appName) {
|
if (this.appName) {
|
||||||
this.filterByAppName();
|
this.filterByAppName();
|
||||||
} else {
|
} else {
|
||||||
this.filterByAppId();
|
this.filterByAppId(this.appId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private filterByAppId() {
|
private filterByAppId(appId) {
|
||||||
this.activiti.getTaskListFilters(this.appId).subscribe(
|
this.activiti.getTaskListFilters(appId).subscribe(
|
||||||
(res: FilterModel[]) => {
|
(res: FilterModel[]) => {
|
||||||
res.forEach((filter) => {
|
res.forEach((filter) => {
|
||||||
this.filterObserver.next(filter);
|
this.filterObserver.next(filter);
|
||||||
@@ -111,18 +111,7 @@ export class ActivitiFilters implements OnInit {
|
|||||||
private filterByAppName() {
|
private filterByAppName() {
|
||||||
this.activiti.getDeployedApplications(this.appName).subscribe(
|
this.activiti.getDeployedApplications(this.appName).subscribe(
|
||||||
application => {
|
application => {
|
||||||
this.activiti.getTaskListFilters(application.id).subscribe(
|
this.filterByAppId(application.id);
|
||||||
(res: FilterModel[]) => {
|
|
||||||
res.forEach((filter) => {
|
|
||||||
this.filterObserver.next(filter);
|
|
||||||
});
|
|
||||||
this.onSuccess.emit(res);
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
console.log(err);
|
|
||||||
this.onError.emit(err);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
Reference in New Issue
Block a user