mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
@@ -0,0 +1,108 @@
|
||||
/*!
|
||||
* @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 { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
|
||||
|
||||
import { ActivitiTaskHeader } from './activiti-task-header.component';
|
||||
import { TranslationMock } from './../assets/translation.service.mock';
|
||||
import { taskDetailsMock } from './../assets/task-details.mock';
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
|
||||
describe('ActivitiTaskHeader', () => {
|
||||
|
||||
let componentHandler: any;
|
||||
let component: ActivitiTaskHeader;
|
||||
let fixture: ComponentFixture<ActivitiTaskHeader>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule
|
||||
],
|
||||
declarations: [
|
||||
ActivitiTaskHeader
|
||||
],
|
||||
providers: [
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
fixture = TestBed.createComponent(ActivitiTaskHeader);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
component.taskDetails = new TaskDetailsModel(taskDetailsMock);
|
||||
|
||||
componentHandler = jasmine.createSpyObj('componentHandler', [
|
||||
'upgradeAllRegistered',
|
||||
'upgradeElement'
|
||||
]);
|
||||
window['componentHandler'] = componentHandler;
|
||||
});
|
||||
|
||||
it('should render empty component if no form details provided', () => {
|
||||
component.taskDetails = undefined;
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.children.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should display assignee', () => {
|
||||
fixture.detectChanges();
|
||||
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .activiti-task-header__value'));
|
||||
expect(formNameEl.nativeElement.innerText).toBe('Wilbur Adams');
|
||||
});
|
||||
|
||||
it('should display placeholder if no assignee', () => {
|
||||
component.taskDetails.assignee = null;
|
||||
fixture.detectChanges();
|
||||
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .activiti-task-header__value'));
|
||||
expect(valueEl.nativeElement.innerText).toBe('TASK_DETAILS.ASSIGNEE.NONE');
|
||||
});
|
||||
|
||||
it('should display due date', () => {
|
||||
component.taskDetails.dueDate = '2016-11-03T15:25:42.749+0000';
|
||||
fixture.detectChanges();
|
||||
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-due-date"] .activiti-task-header__value'));
|
||||
expect(valueEl.nativeElement.innerText).toBe('2016-11-03T15:25:42.749+0000');
|
||||
});
|
||||
|
||||
it('should display placeholder if no due date', () => {
|
||||
component.taskDetails.dueDate = null;
|
||||
fixture.detectChanges();
|
||||
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-due-date"] .activiti-task-header__value'));
|
||||
expect(valueEl.nativeElement.innerText).toBe('TASK_DETAILS.DUE.NONE');
|
||||
});
|
||||
|
||||
it('should display form name', () => {
|
||||
component.formName = 'test form';
|
||||
fixture.detectChanges();
|
||||
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-form-name"] .activiti-task-header__value'));
|
||||
expect(valueEl.nativeElement.innerText).toBe('test form');
|
||||
});
|
||||
|
||||
it('should not display form name if no form name provided', () => {
|
||||
fixture.detectChanges();
|
||||
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-form-name"] .activiti-task-header__value'));
|
||||
expect(valueEl).toBeNull();
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user