Fixed test due new changes

This commit is contained in:
Vito Albano
2016-11-25 18:52:38 +00:00
parent 8e94e67779
commit 9e584925f8
2 changed files with 10 additions and 22 deletions

View File

@@ -72,12 +72,6 @@ describe('ActivitiProcessInstanceDetails', () => {
window['componentHandler'] = componentHandler;
});
it('should load task details when processInstanceId specified', () => {
component.processInstanceId = '123';
fixture.detectChanges();
expect(getProcessSpy).toHaveBeenCalled();
});
it('should not load task details when no processInstanceId is specified', () => {
fixture.detectChanges();
expect(getProcessSpy).not.toHaveBeenCalled();
@@ -89,8 +83,8 @@ describe('ActivitiProcessInstanceDetails', () => {
});
it('should display a header when the processInstanceId is provided', async(() => {
component.processInstanceId = '123';
fixture.detectChanges();
component.ngOnChanges({ 'processInstanceId': new SimpleChange(null, '123') });
fixture.whenStable().then(() => {
fixture.detectChanges();
let headerEl: DebugElement = fixture.debugElement.query(By.css('h2'));
@@ -118,11 +112,6 @@ describe('ActivitiProcessInstanceDetails', () => {
expect(getProcessSpy).toHaveBeenCalledWith('456');
});
it('should reload tasks list when processInstanceId changed', () => {
component.ngOnChanges({ 'processInstanceId': change });
expect(component.tasksList.load).toHaveBeenCalled();
});
it('should NOT fetch new process details when empty changeset made', () => {
component.ngOnChanges({});
expect(getProcessSpy).not.toHaveBeenCalled();

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
import { DebugElement, NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Rx';
@@ -52,7 +52,7 @@ describe('ActivitiProcessInstanceTasks', () => {
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiProcessService
],
schemas: [ NO_ERRORS_SCHEMA ]
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
}));
@@ -103,16 +103,13 @@ describe('ActivitiProcessInstanceTasks', () => {
expect(listEl).toBeNull();
});
it('should call service to get tasks on init', () => {
component.processInstanceDetails = exampleProcessInstance;
fixture.detectChanges();
expect(getProcessTasksSpy).toHaveBeenCalled();
});
it('should display active tasks', () => {
component.processInstanceDetails = exampleProcessInstance;
let change = new SimpleChange(null, exampleProcessInstance);
fixture.detectChanges();
component.ngOnChanges({ 'processInstanceDetails': change });
fixture.whenStable().then(() => {
fixture.detectChanges();
component.ngOnChanges({ 'processInstanceDetails': change });
let listEl = fixture.debugElement.query(By.css('[data-automation-id="active-tasks"]'));
expect(listEl).not.toBeNull();
expect(listEl.queryAll(By.css('li')).length).toBe(1);
@@ -120,9 +117,11 @@ describe('ActivitiProcessInstanceTasks', () => {
});
it('should display completed tasks', () => {
component.processInstanceDetails = exampleProcessInstance;
let change = new SimpleChange(null, exampleProcessInstance);
fixture.detectChanges();
component.ngOnChanges({ 'processInstanceDetails': change });
fixture.whenStable().then(() => {
fixture.detectChanges();
let listEl = fixture.debugElement.query(By.css('[data-automation-id="completed-tasks"]'));
expect(listEl).not.toBeNull();
expect(listEl.queryAll(By.css('li')).length).toBe(1);