Skip to content

Commit b14c47e

Browse files
scastillo-jpEdgar Guaman
authored andcommitted
fix: TT-295 newData undefined resolved
1 parent 9c42be6 commit b14c47e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ describe('EntryFieldsComponent', () => {
9999
description: 'description for active entry',
100100
uri: 'abc',
101101
start_date: moment(mockDate).format(DATE_FORMAT_YEAR),
102-
start_hour: moment(mockDate).format('HH:mm'),
102+
start_hour: moment(mockDate).format('HH:mm')
103+
};
104+
105+
const mockEntryOverlap = {
106+
...entry,
107+
update_last_entry_if_overlap: true
103108
};
104109

105110
beforeEach(waitForAsync(() => {
@@ -252,19 +257,22 @@ describe('EntryFieldsComponent', () => {
252257
});
253258

254259
it('when a start hour is updated, then dispatch UpdateActiveEntry', () => {
260+
component.newData = mockEntryOverlap;
255261
component.activeEntry = entry;
256262
component.setDataToUpdate(entry);
257263
const updatedTime = moment(mockDate).format('HH:mm');
258-
// this.newData.update_last_entry_if_overlap = true;
264+
259265
component.entryForm.patchValue({ start_hour: updatedTime });
260266
spyOn(store, 'dispatch');
261267

262268
component.onUpdateStartHour();
269+
263270
expect(store.dispatch).toHaveBeenCalled();
264271
expect(component.showTimeInbuttons).toEqual(false);
265272
});
266273

267274
it('When start_time is updated, component.last_entry is equal to time entry in the position 1', waitForAsync(() => {
275+
component.newData = mockEntryOverlap;
268276
component.activeEntry = entry;
269277
component.setDataToUpdate(entry);
270278
const updatedTime = moment(mockDate).format('HH:mm');
@@ -276,6 +284,7 @@ describe('EntryFieldsComponent', () => {
276284
}));
277285

278286
it('When start_time is updated for a time entry. UpdateCurrentOrLastEntry action is dispatched', () => {
287+
component.newData = mockEntryOverlap;
279288
component.activeEntry = entry;
280289
component.setDataToUpdate(entry);
281290
const updatedTime = moment(mockDate).subtract(4, 'hours').format('HH:mm');

src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
9494
uri: this.activeEntry.uri,
9595
activity_id: this.activeEntry.activity_id,
9696
start_date: this.activeEntry.start_date,
97-
start_hour: formatDate(this.activeEntry.start_date, 'HH:mm', 'en'),
97+
start_hour: formatDate(this.activeEntry.start_date, 'HH:mm', 'en')
9898
};
9999
this.activateFocus();
100100
});

0 commit comments

Comments
 (0)