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
fix: TT-295 newData undefined resolved
  • Loading branch information
scastillo-jp authored and Edgar Guaman committed Aug 3, 2021
commit b14c47e98674bd52ba72c5896c50b73403aaa07e
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ describe('EntryFieldsComponent', () => {
description: 'description for active entry',
uri: 'abc',
start_date: moment(mockDate).format(DATE_FORMAT_YEAR),
start_hour: moment(mockDate).format('HH:mm'),
start_hour: moment(mockDate).format('HH:mm')
};

const mockEntryOverlap = {
...entry,
update_last_entry_if_overlap: true
};

beforeEach(waitForAsync(() => {
Expand Down Expand Up @@ -252,19 +257,22 @@ describe('EntryFieldsComponent', () => {
});

it('when a start hour is updated, then dispatch UpdateActiveEntry', () => {
component.newData = mockEntryOverlap;
component.activeEntry = entry;
component.setDataToUpdate(entry);
const updatedTime = moment(mockDate).format('HH:mm');
// this.newData.update_last_entry_if_overlap = true;

component.entryForm.patchValue({ start_hour: updatedTime });
spyOn(store, 'dispatch');

component.onUpdateStartHour();

expect(store.dispatch).toHaveBeenCalled();
expect(component.showTimeInbuttons).toEqual(false);
});

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

it('When start_time is updated for a time entry. UpdateCurrentOrLastEntry action is dispatched', () => {
component.newData = mockEntryOverlap;
component.activeEntry = entry;
component.setDataToUpdate(entry);
const updatedTime = moment(mockDate).subtract(4, 'hours').format('HH:mm');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
uri: this.activeEntry.uri,
activity_id: this.activeEntry.activity_id,
start_date: this.activeEntry.start_date,
start_hour: formatDate(this.activeEntry.start_date, 'HH:mm', 'en'),
start_hour: formatDate(this.activeEntry.start_date, 'HH:mm', 'en')
};
this.activateFocus();
});
Expand Down