Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should NOT emit row click event on every other key', async(() => {
let triggered = false;
const keyEvent = new CustomEvent('Keyboard event', { detail: {
keyboardEvent: { key: 'Space' },
row: new ObjectDataRow({ id: 999 })
}});
component.rowClick.subscribe(() => triggered = true);
component.onRowKeyUp(keyEvent);
fixture.whenStable().then(() => {
expect(triggered).toBeFalsy();
});
}));
it('should emit row click event', (done) => {
const row = new ObjectDataRow({
id: '999'
});
const rowEvent = new DataRowEvent(row, null);
component.rowClick.subscribe((taskId) => {
expect(taskId).toEqual('999');
expect(component.getCurrentId()).toEqual('999');
done();
});
component.onRowClick(rowEvent);
});
it('should emit row click event', (done) => {
const row = new ObjectDataRow(fakeUser);
const rowEvent = new DataRowEvent(row, null);
peopleListComponent.clickRow.subscribe((selectedUser) => {
expect(selectedUser.id).toEqual(1);
expect(selectedUser.email).toEqual('fake@mail.com');
expect(peopleListComponent.user.id).toEqual(1);
expect(peopleListComponent.user.email).toEqual('fake@mail.com');
done();
});
peopleListComponent.selectUser(rowEvent);
});
it('should emit row click event', (done) => {
const row = new ObjectDataRow({
entry: {
id: '999'
}
});
const rowEvent = new DataRowEvent(row, null);
component.rowClick.subscribe((taskId) => {
expect(taskId).toEqual('999');
expect(component.getCurrentId()).toEqual('999');
done();
});
component.onRowClick(rowEvent);
});
it('should emit row click event', (done) => {
let row = new ObjectDataRow({
entry: {
id: '999'
}
});
let rowEvent = new DataRowEvent(row, null);
component.rowClick.subscribe((taskId) => {
expect(taskId).toEqual('999');
expect(component.getCurrentId()).toEqual('999');
done();
});
component.onRowClick(rowEvent);
});
it('should emit row action event', (done) => {
const row = new ObjectDataRow(fakeUser);
const removeObj = {
name: 'remove',
title: 'Remove'
};
const rowActionEvent = new DataRowActionEvent(row, removeObj);
peopleListComponent.clickAction.subscribe((selectedAction: UserEventModel) => {
expect(selectedAction.type).toEqual('remove');
expect(selectedAction.value.id).toEqual(1);
expect(selectedAction.value.email).toEqual('fake@mail.com');
done();
});
peopleListComponent.onExecuteRowAction(rowActionEvent);
});
});
it('should emit row click event', (done) => {
const row = new ObjectDataRow({
id: '999'
});
const rowEvent = new DataRowEvent(row, null);
component.rowClick.subscribe((taskId) => {
expect(taskId).toEqual('999');
expect(component.getCurrentId()).toEqual('999');
done();
});
component.onRowClick(rowEvent);
});
addRow() {
const id = this.data.getRows().length + 1;
const row = new ObjectDataRow({
id: id,
name: 'Name ' + id,
createdOn: new Date(),
icon: 'material-icons://extension',
createdBy: this._createdBy
});
this.data.getRows().push(row);
this.data.sort();
}
onProcessDetailsTaskClick(event: TaskDetailsEvent): void {
event.preventDefault();
this.activeTab = this.tabs.tasks;
const taskId = event.value.id;
const processTaskDataRow = new ObjectDataRow({
id: taskId,
name: event.value.name || 'No name',
created: event.value.created
});
this.activitifilter.selectFilter(null);
if (this.taskList) {
this.taskList.setCustomDataSource([processTaskDataRow]);
this.taskList.selectTask(taskId);
}
this.currentTaskId = taskId;
}
const rows = objects.map((obj) => new ObjectDataRow(obj));
this.data.setRows(rows);