Skip to content

Commit ab27add

Browse files
authored
fix: TT-117 two entries in progress bug (#627)
* fix: TT-117 two entries in progress bug * fix: TT-117 creating new test
1 parent e72fd55 commit ab27add

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,22 @@ describe('DetailsFieldsComponent', () => {
128128
expect(component).toBeTruthy();
129129
});
130130

131-
it('onClearedComponent project id and name it is set to empty', () => {
131+
it('onClearedComponent project id and name are set to empty', () => {
132132
component.onClearedComponent(null);
133133

134134
expect(component.project_id.value).toBe('');
135135
expect(component.project_name.value).toBe('');
136136
});
137137

138-
it('onSelectedProject project id and name it is set using event data', () => {
138+
it('onSelectedProject project id and name are set using event data', () => {
139139
spyOn(component.entryForm, 'patchValue');
140140

141141
component.onSelectedProject( {id: 'id', search_field: 'foo'} );
142142

143143
expect(component.entryForm.patchValue).toHaveBeenCalledWith( { project_id: 'id', project_name: 'foo', } );
144144
});
145145

146-
it('if form is invalid then no save is emited', () => {
146+
it('if form is invalid then saveEntry is not emited', () => {
147147
spyOn(component.saveEntry, 'emit');
148148

149149
component.onSubmit();
@@ -172,6 +172,7 @@ describe('DetailsFieldsComponent', () => {
172172
it('should emit ngOnChange without data', () => {
173173
component.entryToEdit = null;
174174
component.ngOnChanges();
175+
expect(component.shouldRestartEntry).toBeFalse();
175176
expect(component.entryForm.value).toEqual(initialData);
176177
});
177178

@@ -243,6 +244,7 @@ describe('DetailsFieldsComponent', () => {
243244
},
244245
shouldRestartEntry: false
245246
};
247+
246248
expect(component.saveEntry.emit).toHaveBeenCalledWith(data);
247249
});
248250

@@ -298,14 +300,23 @@ describe('DetailsFieldsComponent', () => {
298300
fixture.componentInstance.ngOnChanges();
299301

300302
expect(component.goingToWorkOnThis).toBeFalse();
303+
expect(component.shouldRestartEntry).toBeFalse();
301304
});
302305

303-
it('when editing entry that already finished, then the entry should not be marked as running', () => {
304-
component.entryToEdit = { ...entryToEdit, running: false };
306+
it('when editing entry is running, shouldRestartEntry should be false', () => {
307+
component.entryToEdit = { ...entryToEdit, running: true };
305308

306309
fixture.componentInstance.ngOnChanges();
307310

308-
expect(component.goingToWorkOnThis).toBeFalse();
311+
expect(component.goingToWorkOnThis).toBeTrue();
312+
expect(component.shouldRestartEntry).toBeFalse();
313+
});
314+
315+
it('when editing entry change to going to work on this shouldRestartEntry should be true', () => {
316+
component.onGoingToWorkOnThisChange({ currentTarget: { checked: true } });
317+
318+
expect(component.goingToWorkOnThis).toBeTrue();
319+
expect(component.shouldRestartEntry).toBeTrue();
309320
});
310321

311322
it('when submitting a entry that is currently running, the end date should not be sent ', () => {
@@ -328,6 +339,7 @@ describe('DetailsFieldsComponent', () => {
328339
},
329340
shouldRestartEntry: false
330341
};
342+
331343
expect(component.saveEntry.emit).toHaveBeenCalledWith(data);
332344
});
333345

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
126126

127127
ngOnChanges(): void {
128128
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running : false;
129+
this.shouldRestartEntry = false;
129130
if (this.entryToEdit) {
130131
this.selectedTechnologies = this.entryToEdit.technologies;
131132
const projectFound = this.listProjects.find((project) => project.id === this.entryToEdit.project_id);

0 commit comments

Comments
 (0)