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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(change)="onSubmit()"
class="form-control"
formControlName="activity_id"
[class.is-invalid]="activity_id.invalid && activity_id.touched"
[class.is-invalid]="activity_id.invalid && activity_id.touched || activity_id.value == '-1'"
required>
<option value="-1"></option>
<option *ngFor="let activity of activities" value="{{ activity.id }}">{{ activity.name }}</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { DATE_FORMAT_YEAR } from 'src/environments/environment';
import { FeatureManagerService } from './../../../shared/feature-toggles/feature-toggle-manager.service';
import { FeatureToggleGeneralService } from './../../../shared/feature-toggles/feature-toggle-general/feature-toggle-general.service';
import { FeatureToggle } from 'src/environments/enum';
import { By } from '@angular/platform-browser';


describe('EntryFieldsComponent', () => {
Expand Down Expand Up @@ -466,6 +467,15 @@ describe('EntryFieldsComponent', () => {
expect(featureToggleGeneralService.isActivated).toHaveBeenCalled();
});
});

it('toastrService should be called when the activity field is empty', () => {
fixture.detectChanges();
const select: HTMLSelectElement = fixture.debugElement.query(By.css('select')).nativeElement;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a line white after this line

spyOn(toastrServiceStub, 'error');
select.value = select.options[0].value;
select.dispatchEvent(new Event('change'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a line white after this line

expect(toastrServiceStub.error).toHaveBeenCalled();
});
});


Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
}

onSubmit() {
if (this.entryForm.value.activity_id === '-1') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty option has an id -1 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.toastrService.error('Please enter a valid activity');
return;
}
this.store.dispatch(new entryActions.UpdateEntryRunning({ ...this.newData, ...this.entryForm.value }));
}

Expand Down