mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-2494] Task Standalone - Provide a way to attach a form (#3459)
* button added for task standalone * attach form component added * slide-toggle position fixed * tests added * rebase fixed * review fix * test added & fixes * tests fixes * refresh task details * tests fixed * attachFormToATask test added * formPreview test fixed * adf-form test fixed
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AttachFormComponent } from './attach-form.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
import { TaskListService } from './../services/tasklist.service';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
describe('AttachFormComponent', () => {
|
||||
let component: AttachFormComponent;
|
||||
let fixture: ComponentFixture<AttachFormComponent>;
|
||||
let element: HTMLElement;
|
||||
let taskService: TaskListService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
ProcessTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(AttachFormComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
taskService = TestBed.get(TaskListService);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should emit cancel event if clicked on Cancel Button ', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const emitSpy = spyOn(component.cancelAttachForm, 'emit');
|
||||
const el = fixture.nativeElement.querySelector('#adf-no-form-cancel-button');
|
||||
el.click();
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should call attachFormToATask if clicked on Complete Button', async(() => {
|
||||
component.taskId = 1;
|
||||
component.formKey = 2;
|
||||
spyOn(taskService, 'attachFormToATask').and.returnValue(Observable.of(true));
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-no-form-attach-form-button')).toBeDefined();
|
||||
const el = fixture.nativeElement.querySelector('#adf-no-form-attach-form-button');
|
||||
el.click();
|
||||
expect(taskService.attachFormToATask).toHaveBeenCalledWith(1, 2);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show the adf-form of the selected form', async(() => {
|
||||
component.taskId = 1;
|
||||
component.formKey = 12;
|
||||
fixture.detectChanges();
|
||||
const formContainer = fixture.debugElement.nativeElement.querySelector('adf-form');
|
||||
fixture.whenStable().then(() => {
|
||||
expect(formContainer).toBeDefined();
|
||||
expect(formContainer).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
});
|
Reference in New Issue
Block a user