mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
* remove temporary file from repo * fix: alfresco-api.service * new: auth.service.ts - new auth.service.ts implementation - deprecation warning for AlfrescoAuthenticationService - fix ‘clean-build’ typo - extra vscode settings for ‘.d.ts’ files * use AuthService internally * new: content.service.ts - deprecation warning for AlfrescoContentService - use new ContentService internally * new: settings.service.ts - new SettingsService - deprecation warning for AlfrescoSettingsService - using new SettingsService internally * new: translate.service and translate-loader.service - custom TranslateLoader becomes AlfrescoTranslateLoader - custom TranslateService becomes AlfrescoTranslateService - deprecation notices for old service and loader implementations * fix: document list * fix: search * fix: tag also fixes #1364 * fix: activiti form * fix: activiti tasklist, improve unit tests * fix: activiti processlist, unit tests improvements * fix: diagram component * fix: analytics component * fix: upload component - fix numerous issues with unit tests (hidden by ‘any’ type) - test improvements * fix: webscript * fix: userinfo unit tests * code fixes * fix 'beforeAll' issue * tasklist unit testing improvements * fix: form unit tests * fix: unit tests
179 lines
7.1 KiB
TypeScript
179 lines
7.1 KiB
TypeScript
/*!
|
|
* @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 { SimpleChange } from '@angular/core';
|
|
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
|
import { Observable } from 'rxjs/Rx';
|
|
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
|
|
import { ActivitiTaskListService } from '../services/activiti-tasklist.service';
|
|
import { ActivitiChecklist } from './activiti-checklist.component';
|
|
import { TaskDetailsModel } from '../models/task-details.model';
|
|
|
|
declare let jasmine: any;
|
|
|
|
const fakeTaskDetail = new TaskDetailsModel({
|
|
id: 'fake-check-id',
|
|
name: 'fake-check-name'
|
|
});
|
|
|
|
describe('ActivitiChecklist', () => {
|
|
|
|
let checklistComponent: ActivitiChecklist;
|
|
let fixture: ComponentFixture<ActivitiChecklist>;
|
|
let element: HTMLElement;
|
|
let showChecklistDialog, closeCheckDialogButton;
|
|
|
|
beforeEach(async(() => {
|
|
TestBed.configureTestingModule({
|
|
imports: [
|
|
CoreModule.forRoot()
|
|
],
|
|
declarations: [
|
|
ActivitiChecklist
|
|
],
|
|
providers: [
|
|
ActivitiTaskListService
|
|
]
|
|
}).compileComponents().then(() => {
|
|
let translateService = TestBed.get(AlfrescoTranslateService);
|
|
spyOn(translateService, 'addTranslationFolder').and.stub();
|
|
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
|
|
|
|
fixture = TestBed.createComponent(ActivitiChecklist);
|
|
checklistComponent = fixture.componentInstance;
|
|
element = fixture.nativeElement;
|
|
|
|
fixture.detectChanges();
|
|
});
|
|
}));
|
|
|
|
it('should show people component title', () => {
|
|
expect(element.querySelector('#checklist-label')).toBeDefined();
|
|
expect(element.querySelector('#checklist-label')).not.toBeNull();
|
|
});
|
|
|
|
it('should show no checklist message', () => {
|
|
expect(element.querySelector('#checklist-none-message')).not.toBeNull();
|
|
expect(element.querySelector('#checklist-none-message').textContent).toContain('TASK_DETAILS.CHECKLIST.NONE');
|
|
});
|
|
|
|
describe('when interact with people dialog', () => {
|
|
|
|
beforeEach(() => {
|
|
checklistComponent.taskId = 'fake-task-id';
|
|
checklistComponent.checklist = [];
|
|
fixture.detectChanges();
|
|
showChecklistDialog = <HTMLElement> element.querySelector('#add-checklist');
|
|
closeCheckDialogButton = <HTMLElement> element.querySelector('#close-check-dialog');
|
|
});
|
|
|
|
it('should show dialog when clicked on add', () => {
|
|
expect(showChecklistDialog).not.toBeNull();
|
|
showChecklistDialog.click();
|
|
|
|
expect(element.querySelector('#checklist-dialog')).not.toBeNull();
|
|
expect(element.querySelector('#add-checklist-title')).not.toBeNull();
|
|
expect(element.querySelector('#add-checklist-title').textContent).toContain('New Check');
|
|
});
|
|
|
|
it('should close dialog when clicked on cancel', () => {
|
|
showChecklistDialog.click();
|
|
expect(element.querySelector('#checklist-dialog').getAttribute('open')).not.toBeNull();
|
|
closeCheckDialogButton.click();
|
|
expect(element.querySelector('#checklist-dialog').getAttribute('open')).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('when there are task checklist', () => {
|
|
|
|
beforeEach(() => {
|
|
checklistComponent.taskId = 'fake-task-id';
|
|
checklistComponent.checklist = [];
|
|
fixture.detectChanges();
|
|
showChecklistDialog = <HTMLElement> element.querySelector('#add-checklist');
|
|
});
|
|
|
|
beforeEach(() => {
|
|
jasmine.Ajax.install();
|
|
});
|
|
|
|
afterEach(() => {
|
|
jasmine.Ajax.uninstall();
|
|
});
|
|
|
|
it('should show task checklist', () => {
|
|
checklistComponent.checklist.push(fakeTaskDetail);
|
|
fixture.detectChanges();
|
|
expect(element.querySelector('#check-fake-check-id')).not.toBeNull();
|
|
expect(element.querySelector('#check-fake-check-id').textContent).toContain('fake-check-name');
|
|
});
|
|
|
|
it('should add checklist', async(() => {
|
|
showChecklistDialog.click();
|
|
let addButtonDialog = <HTMLElement> element.querySelector('#add-check');
|
|
addButtonDialog.click();
|
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
|
status: 200,
|
|
contentType: 'json',
|
|
responseText: {id: 'fake-check-added-id', name: 'fake-check-added-name'}
|
|
});
|
|
fixture.whenStable().then(() => {
|
|
fixture.detectChanges();
|
|
expect(element.querySelector('#check-fake-check-added-id')).not.toBeNull();
|
|
expect(element.querySelector('#check-fake-check-added-id').textContent).toContain('fake-check-added-name');
|
|
});
|
|
}));
|
|
|
|
it('should show load task checklist on change', async(() => {
|
|
checklistComponent.taskId = 'new-fake-task-id';
|
|
checklistComponent.checklist.push(fakeTaskDetail);
|
|
fixture.detectChanges();
|
|
let change = new SimpleChange(null, 'new-fake-task-id');
|
|
checklistComponent.ngOnChanges({
|
|
taskId: change
|
|
});
|
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
|
status: 200,
|
|
contentType: 'json',
|
|
responseText: {data: [{id: 'fake-check-changed-id', name: 'fake-check-changed-name'}]}
|
|
});
|
|
fixture.whenStable().then(() => {
|
|
fixture.detectChanges();
|
|
expect(element.querySelector('#check-fake-check-changed-id')).not.toBeNull();
|
|
expect(element.querySelector('#check-fake-check-changed-id').textContent).toContain('fake-check-changed-name');
|
|
});
|
|
}));
|
|
|
|
it('should show empty checklist when task id is null', async(() => {
|
|
checklistComponent.taskId = 'new-fake-task-id';
|
|
checklistComponent.checklist.push(fakeTaskDetail);
|
|
fixture.detectChanges();
|
|
checklistComponent.taskId = null;
|
|
let change = new SimpleChange(null, 'new-fake-task-id');
|
|
checklistComponent.ngOnChanges({
|
|
taskId: change
|
|
});
|
|
fixture.whenStable().then(() => {
|
|
fixture.detectChanges();
|
|
expect(element.querySelector('#checklist-none-message')).not.toBeNull();
|
|
expect(element.querySelector('#checklist-none-message').textContent).toContain('TASK_DETAILS.CHECKLIST.NONE');
|
|
});
|
|
}));
|
|
});
|
|
|
|
});
|