mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2452] Task Standalone component (#3084)
* Add a new standalone component to show when there is no form attached to a task.
This commit is contained in:
committed by
Eugenio Romano
parent
c578529b15
commit
afb91cf062
@@ -0,0 +1,139 @@
|
||||
/*!
|
||||
* @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 { TaskStandaloneComponent } from './task-standalone.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {
|
||||
MatButtonModule,
|
||||
MatCardModule
|
||||
} from '@angular/material';
|
||||
|
||||
describe('TaskStandaloneComponent', () => {
|
||||
let component: TaskStandaloneComponent;
|
||||
let fixture: ComponentFixture<TaskStandaloneComponent>;
|
||||
let element: HTMLElement;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
||||
declarations: [
|
||||
TaskStandaloneComponent
|
||||
],
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatCardModule
|
||||
]
|
||||
}).compileComponents().then(() => {
|
||||
fixture = TestBed.createComponent(TaskStandaloneComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show Completed message if isCompleted is true', async(() => {
|
||||
component.isCompleted = true;
|
||||
fixture.detectChanges();
|
||||
const completedFormElement = fixture.debugElement.nativeElement.querySelector('#adf-completed-form-message');
|
||||
const completedFormSubElement = fixture.debugElement.nativeElement.querySelector('.adf-no-form-submessage');
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#adf-no-form-message')).toBeNull();
|
||||
expect(completedFormElement).toBeDefined();
|
||||
expect(completedFormElement.innerText.trim()).toBe('ADF_TASK_LIST.STANDALONE_TASK.COMPLETE_TASK_MESSAGE');
|
||||
expect(completedFormSubElement).toBeDefined();
|
||||
expect(completedFormSubElement.innerText).toBe('ADF_TASK_LIST.STANDALONE_TASK.COMPLETE_TASK_SUB_MESSAGE');
|
||||
expect(element.querySelector('.adf-no-form-mat-card-actions')).toBeDefined();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show No form message if isCompleted is false', async(() => {
|
||||
component.isCompleted = false;
|
||||
fixture.detectChanges();
|
||||
const noformElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-message');
|
||||
fixture.whenStable().then(() => {
|
||||
expect(noformElement).toBeDefined();
|
||||
expect(noformElement.innerText).toBe('ADF_TASK_LIST.STANDALONE_TASK.NO_FORM_MESSAGE');
|
||||
expect(element.querySelector('#adf-completed-form-message')).toBeNull();
|
||||
expect(element.querySelector('.adf-no-form-submessage')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should hide Cancel button by default', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-no-form-cancel-button')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit cancel event if clicked on Cancel Button ', async(() => {
|
||||
component.hideCancelButton = false;
|
||||
component.isCompleted = false;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const emitSpy = spyOn(component.cancel, 'emit');
|
||||
const el = fixture.nativeElement.querySelector('#adf-no-form-cancel-button');
|
||||
el.click();
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should hide Cancel button if hideCancelButton is true', async(() => {
|
||||
component.hideCancelButton = true;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-no-form-cancel-button')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should hide Cancel button if isCompleted is true', async(() => {
|
||||
component.isCompleted = true;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-no-form-cancel-button')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit complete event if clicked on Complete Button', async(() => {
|
||||
component.hasCompletePermission = true;
|
||||
component.isCompleted = false;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const emitSpy = spyOn(component.complete, 'emit');
|
||||
expect(element.querySelector('#adf-no-form-complete-button')).toBeDefined();
|
||||
const el = fixture.nativeElement.querySelector('#adf-no-form-complete-button');
|
||||
el.click();
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should hide Complete button if isCompleted is true', async(() => {
|
||||
component.isCompleted = true;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-no-form-complete-button')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should hide Complete button if hasCompletePermission is false', async(() => {
|
||||
component.hasCompletePermission = false;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-no-form-complete-button')).toBeNull();
|
||||
});
|
||||
}));
|
||||
});
|
Reference in New Issue
Block a user