TSK-1349: added unit test for workbasket dual list (#1256)
This commit is contained in:
parent
bdb56c949f
commit
7b96490b65
|
@ -28,10 +28,10 @@
|
|||
</div>
|
||||
|
||||
<!-- WORKBASKET LIST -->
|
||||
<div infiniteScroll [infiniteScrollDistance]="1" [infiniteScrollThrottle]="50" (scrolled)="onScroll()"
|
||||
<div class="workbasket-list" infiniteScroll [infiniteScrollDistance]="1" [infiniteScrollThrottle]="50" (scrolled)="onScroll()"
|
||||
[scrollWindow]="false" class="infinite-scroll">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item"
|
||||
<li class="list-group-item workbasket-list__distribution-targets"
|
||||
*ngFor="let distributionTarget of distributionTargets | selectWorkbaskets: distributionTargetsSelected: side"
|
||||
[class.selected]="distributionTarget.selected" type="text"
|
||||
(click)="distributionTarget.selected = !distributionTarget.selected">
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Component, DebugElement, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { WorkbasketDualListComponent } from './workbasket-dual-list.component';
|
||||
import { Filter } from '../../../shared/models/filter';
|
||||
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
|
||||
import { ICONTYPES } from '../../../shared/models/icon-types';
|
||||
import { SelectWorkBasketPipe } from '../../../shared/pipes/select-workbaskets.pipe';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { workbasketReadStateMock } from '../../../shared/store/mock-data/mock-store';
|
||||
import { Side } from '../workbasket-distribution-targets/workbasket-distribution-targets.component';
|
||||
|
||||
@Component({ selector: 'taskana-shared-filter', template: '' })
|
||||
class FilterStub {
|
||||
@Output() performFilter = new EventEmitter<Filter>();
|
||||
}
|
||||
|
||||
@Component({ selector: 'taskana-shared-spinner', template: '' })
|
||||
class SpinnerStub {
|
||||
@Input() isRunning: boolean;
|
||||
}
|
||||
|
||||
@Component({ selector: 'taskana-administration-icon-type', template: '' })
|
||||
class IconTypeStub {
|
||||
@Input() type: ICONTYPES = ICONTYPES.ALL;
|
||||
@Input() text: string;
|
||||
}
|
||||
|
||||
describe('WorkbasketDualListComponent', () => {
|
||||
let fixture: ComponentFixture<WorkbasketDualListComponent>;
|
||||
let debugElement: DebugElement;
|
||||
let component: WorkbasketDualListComponent;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [InfiniteScrollModule, BrowserAnimationsModule],
|
||||
declarations: [WorkbasketDualListComponent, FilterStub, SpinnerStub, IconTypeStub, SelectWorkBasketPipe],
|
||||
providers: []
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(WorkbasketDualListComponent);
|
||||
debugElement = fixture.debugElement;
|
||||
component = fixture.componentInstance;
|
||||
component.distributionTargets = workbasketReadStateMock.paginatedWorkbasketsSummary.workbaskets;
|
||||
component.distributionTargetsSelected = [];
|
||||
component.side = Side.LEFT;
|
||||
}));
|
||||
|
||||
it('should create component', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should set sideNumber to 0 when side is Side.LEFT', () => {
|
||||
fixture.detectChanges();
|
||||
expect(component.sideNumber).toBe(0);
|
||||
});
|
||||
|
||||
it('should select all distribution targets', () => {
|
||||
component.selectAll(true);
|
||||
component.distributionTargets.forEach((element) => {
|
||||
expect(element['selected']).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should emit side when scrolling', () => {
|
||||
const scrollingEmitSpy = jest.spyOn(component.scrolling, 'emit');
|
||||
component.onScroll();
|
||||
expect(scrollingEmitSpy).toHaveBeenCalledWith(component.side);
|
||||
});
|
||||
|
||||
it('should emit filter model and side when performing filter', () => {
|
||||
const performDualListFilterSpy = jest.spyOn(component.performDualListFilter, 'emit');
|
||||
const filterModelMock: Filter = { filterParams: 'filter' };
|
||||
component.performAvailableFilter(filterModelMock);
|
||||
expect(performDualListFilterSpy).toHaveBeenCalledWith({ filterBy: filterModelMock, side: component.side });
|
||||
});
|
||||
|
||||
it('should change toolbar state', () => {
|
||||
expect(component.toolbarState).toBe(false);
|
||||
component.changeToolbarState(true);
|
||||
expect(component.toolbarState).toBe(true);
|
||||
});
|
||||
|
||||
it('should display all available workbaskets', () => {
|
||||
fixture.detectChanges();
|
||||
const distributionTargetList = debugElement.nativeElement.getElementsByClassName(
|
||||
'workbasket-list__distribution-targets'
|
||||
);
|
||||
expect(distributionTargetList).toHaveLength(5);
|
||||
});
|
||||
});
|
|
@ -194,7 +194,7 @@ export const workbasketReadStateMock = {
|
|||
key: 'USER-2-1',
|
||||
name: 'PPK User 1 KSC 2',
|
||||
domain: 'DOMAIN_A',
|
||||
type: 'PERSONAL',
|
||||
type: ICONTYPES.PERSONAL,
|
||||
description: 'PPK User 1 KSC 2',
|
||||
owner: '',
|
||||
custom1: '',
|
||||
|
@ -212,7 +212,7 @@ export const workbasketReadStateMock = {
|
|||
key: 'USER-1-2',
|
||||
name: 'PPK User 2 KSC 1',
|
||||
domain: 'DOMAIN_A',
|
||||
type: 'PERSONAL',
|
||||
type: ICONTYPES.PERSONAL,
|
||||
description: 'PPK User 2 KSC 1',
|
||||
owner: 'Peter Maier',
|
||||
custom1: 'custom1',
|
||||
|
@ -230,7 +230,7 @@ export const workbasketReadStateMock = {
|
|||
key: 'USER-2-2',
|
||||
name: 'PPK User 2 KSC 2',
|
||||
domain: 'DOMAIN_A',
|
||||
type: 'PERSONAL',
|
||||
type: ICONTYPES.PERSONAL,
|
||||
description: 'PPK User 2 KSC 2',
|
||||
owner: '',
|
||||
custom1: '',
|
||||
|
@ -248,7 +248,7 @@ export const workbasketReadStateMock = {
|
|||
key: 'TPK_VIP',
|
||||
name: 'Themenpostkorb VIP',
|
||||
domain: 'DOMAIN_A',
|
||||
type: 'TOPIC',
|
||||
type: ICONTYPES.TOPIC,
|
||||
description: 'Themenpostkorb VIP',
|
||||
owner: '',
|
||||
custom1: '',
|
||||
|
@ -266,7 +266,7 @@ export const workbasketReadStateMock = {
|
|||
key: 'TPK_VIP_2',
|
||||
name: 'Themenpostkorb VIP 2',
|
||||
domain: 'DOMAIN_A',
|
||||
type: 'TOPIC',
|
||||
type: ICONTYPES.TOPIC,
|
||||
description: 'Themenpostkorb VIP',
|
||||
owner: '',
|
||||
custom1: '',
|
||||
|
|
Loading…
Reference in New Issue