mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-237] Fix tests
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
(mouseout)="t.close()">
|
(mouseout)="t.close()">
|
||||||
<a class="flex-sm-fill text-sm-center nav-link active bg-info"
|
<a class="flex-sm-fill text-sm-center nav-link active bg-info"
|
||||||
cdkDrag
|
cdkDrag
|
||||||
(cdkDragStarted)="onDrag($event)"
|
(cdkDragStarted)="onDrag(i)"
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
[ngClass]="{'chip-selected disabled': (editable && c.editMode) || dragged === i}"
|
[ngClass]="{'chip-selected disabled': (editable && c.editMode) || dragged === i}"
|
||||||
(click)="chipsSelected($event, i);">
|
(click)="chipsSelected($event, i);">
|
||||||
|
@@ -134,18 +134,18 @@ describe('ChipsComponent test suite', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should save chips item index when drag and drop start', fakeAsync(() => {
|
it('should save chips item index when drag and drop start', fakeAsync(() => {
|
||||||
const de = chipsFixture.debugElement.query(By.css('div.nav-item'));
|
const de = chipsFixture.debugElement.query(By.css('a'));
|
||||||
|
|
||||||
de.triggerEventHandler('dragstart', null);
|
de.triggerEventHandler('cdkDragStarted', null);
|
||||||
|
|
||||||
expect(chipsComp.dragged).toBe(0);
|
expect(chipsComp.dragged).toBe(0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should update chips item order when drag and drop end', fakeAsync(() => {
|
it('should update chips item order when drag and drop end', fakeAsync(() => {
|
||||||
spyOn(chipsComp.chips, 'updateOrder');
|
spyOn(chipsComp.chips, 'updateOrder');
|
||||||
const de = chipsFixture.debugElement.query(By.css('div.nav-item'));
|
const de = chipsFixture.debugElement.query(By.css('div[role="list"]'));
|
||||||
|
|
||||||
de.triggerEventHandler('dragend', null);
|
de.triggerEventHandler('cdkDropListDropped', { previousIndex: 0, currentIndex: 1 });
|
||||||
|
|
||||||
expect(chipsComp.dragged).toBe(-1);
|
expect(chipsComp.dragged).toBe(-1);
|
||||||
expect(chipsComp.chips.updateOrder).toHaveBeenCalled();
|
expect(chipsComp.chips.updateOrder).toHaveBeenCalled();
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
CdkDrag,
|
CdkDrag,
|
||||||
CdkDragDrop,
|
CdkDragDrop,
|
||||||
CdkDragStart,
|
|
||||||
CdkDropList,
|
CdkDropList,
|
||||||
moveItemInArray,
|
moveItemInArray,
|
||||||
} from '@angular/cdk/drag-drop';
|
} from '@angular/cdk/drag-drop';
|
||||||
@@ -101,14 +100,18 @@ export class ChipsComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDrag(event: CdkDragStart<ChipsItem[]>) {
|
onDrag(index) {
|
||||||
this.isDragging.next(true);
|
this.isDragging.next(true);
|
||||||
|
this.dragged = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
onDrop(event: CdkDragDrop<ChipsItem[]>) {
|
onDrop(event: CdkDragDrop<ChipsItem[]>) {
|
||||||
|
console.log('onDrop', event);
|
||||||
moveItemInArray(this.chips.chipsItems.getValue(), event.previousIndex, event.currentIndex);
|
moveItemInArray(this.chips.chipsItems.getValue(), event.previousIndex, event.currentIndex);
|
||||||
this.chips.updateOrder();
|
this.chips.updateOrder();
|
||||||
this.isDragging.next(false);
|
this.isDragging.next(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
showTooltip(tooltip: NgbTooltip, index, field?) {
|
showTooltip(tooltip: NgbTooltip, index, field?) {
|
||||||
tooltip.close();
|
tooltip.close();
|
||||||
if (this.isDragging.value) {
|
if (this.isDragging.value) {
|
||||||
|
Reference in New Issue
Block a user