mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
[ADF-1103] Add custom tslint rules to avoid unwanted Class and File name prefix (#2087)
* custom tslint rules adf project name files * filename and class prefix rule * filename process service mock * fix spec filename * fix demo shell * rename mock * alias deprecated name class * core rename services * fix pacakge.json adf-rules * add exclude in whitelist
This commit is contained in:
committed by
Denys Vuika
parent
acb69503e7
commit
8b93c0b5ed
@@ -0,0 +1,133 @@
|
||||
/*!
|
||||
* @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 { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
|
||||
import { exampleProcess, processEnded } from './../assets/process.model.mock';
|
||||
import { TranslationMock } from './../assets/translation.service.mock';
|
||||
import { ProcessInstance } from './../models/process-instance.model';
|
||||
import { ProcessService } from './../services/process.service';
|
||||
import { ProcessCommentsComponent } from './process-comments.component';
|
||||
import { ProcessInstanceHeaderComponent } from './process-instance-header.component';
|
||||
|
||||
describe('ProcessInstanceHeaderComponent', () => {
|
||||
|
||||
let componentHandler: any;
|
||||
let component: ProcessInstanceHeaderComponent;
|
||||
let fixture: ComponentFixture<ProcessInstanceHeaderComponent>;
|
||||
let element: HTMLElement;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
declarations: [
|
||||
ProcessInstanceHeaderComponent,
|
||||
ProcessCommentsComponent
|
||||
],
|
||||
providers: [
|
||||
ProcessService,
|
||||
{provide: AlfrescoTranslationService, useClass: TranslationMock}
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
fixture = TestBed.createComponent(ProcessInstanceHeaderComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
|
||||
component.processInstance = new ProcessInstance(exampleProcess);
|
||||
|
||||
componentHandler = jasmine.createSpyObj('componentHandler', [
|
||||
'upgradeAllRegistered',
|
||||
'upgradeElement'
|
||||
]);
|
||||
window['componentHandler'] = componentHandler;
|
||||
});
|
||||
|
||||
it('should render empty component if no form details provided', () => {
|
||||
component.processInstance = undefined;
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.children.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should display started by user', () => {
|
||||
fixture.detectChanges();
|
||||
let formValueEl = fixture.debugElement.query(By.css('[data-automation-id="header-started-by"] .activiti-process-header__value'));
|
||||
expect(formValueEl).not.toBeNull();
|
||||
expect(formValueEl.nativeElement.innerText).toBe('Bob Jones');
|
||||
});
|
||||
|
||||
it('should display empty started by user if user unknown', () => {
|
||||
component.processInstance.startedBy = null;
|
||||
fixture.detectChanges();
|
||||
let formValueEl = fixture.debugElement.query(By.css('[data-automation-id="header-started-by"] .activiti-process-header__value'));
|
||||
expect(formValueEl).not.toBeNull();
|
||||
expect(formValueEl.nativeElement.innerText).toBe('');
|
||||
});
|
||||
|
||||
it('should display process start date', () => {
|
||||
component.processInstance.started = '2016-11-10T03:37:30.010+0000';
|
||||
fixture.detectChanges();
|
||||
let formValueEl = fixture.debugElement.query(By.css('[data-automation-id="header-started"] .activiti-process-header__value'));
|
||||
expect(formValueEl).not.toBeNull();
|
||||
expect(formValueEl.nativeElement.innerText).toBe('Nov 10, 2016, 3:37:30 AM');
|
||||
});
|
||||
|
||||
it('should display ended date if process is ended', () => {
|
||||
component.processInstance.ended = '2016-11-10T03:37:30.010+0000';
|
||||
fixture.detectChanges();
|
||||
let formValueEl = fixture.debugElement.query(By.css('[data-automation-id="header-status"] .activiti-process-header__value'));
|
||||
expect(formValueEl).not.toBeNull();
|
||||
expect(formValueEl.nativeElement.innerText).toBe('Nov 10, 2016, 3:37:30 AM');
|
||||
});
|
||||
|
||||
it('should render the button show diagram as default', () => {
|
||||
fixture.detectChanges();
|
||||
let formValueEl = fixture.debugElement.query(By.css('[data-automation-id="header-show-diagram"]'));
|
||||
expect(formValueEl).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should render the button show diagram enabled as default', () => {
|
||||
fixture.detectChanges();
|
||||
let showButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#show-diagram-button');
|
||||
expect(showButton).toBeDefined();
|
||||
expect(showButton.disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should render the button show diagram disabled', () => {
|
||||
component.processInstance = new ProcessInstance(processEnded);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let showButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#show-diagram-button');
|
||||
expect(showButton).toBeDefined();
|
||||
expect(showButton.disabled).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should NOT render the button show diagram is the property showDiagram is false', () => {
|
||||
component.showDiagram = false;
|
||||
fixture.detectChanges();
|
||||
let formValueEl = fixture.debugElement.query(By.css('[data-automation-id="header-show-pippo"]'));
|
||||
expect(formValueEl).toBeNull();
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user