Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: TT-141 Create test to validate the isEdit flag of the DetailsFi…
…elds component
  • Loading branch information
VanessaIniguezG committed Feb 23, 2021
commit 46be8e9d1938cce5ed6fcc35534fda91a0555105
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ describe('DetailsFieldsComponent', () => {

it('should emit ngOnChange without data', () => {
component.entryToEdit = null;
component.isEdit = true;
component.ngOnChanges();
expect(component.shouldRestartEntry).toBeFalse();
expect(component.entryForm.value).toEqual(initialData);
Expand All @@ -192,6 +193,7 @@ describe('DetailsFieldsComponent', () => {
technology: '',
};
component.entryToEdit = null;
component.isEdit = true;
component.ngOnChanges();
expect(component.entryForm.value).toEqual(formValue);
});
Expand Down Expand Up @@ -443,6 +445,20 @@ describe('DetailsFieldsComponent', () => {
expect(component.projectSelected.emit).toHaveBeenCalledWith(data);
});

it('should clear the form fields', () => {
spyOn(component, 'cleanForm');
component.isEdit = true;
component.ngOnChanges();
expect(component.cleanForm).toHaveBeenCalled();
});

it('should persist entry form value', () => {
spyOn(component, 'cleanForm');
component.isEdit = false;
component.ngOnChanges();
expect(component.cleanForm).toHaveBeenCalledTimes(0);
});

/*
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
});
} else {
if (this.isEdit) {
this.cleanForm();
this.cleanForm();
}
}
}
Expand Down