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: TTL-898 tests
  • Loading branch information
mmaquina committed Jul 10, 2023
commit 823743bf11bd105a0665c3eedf94cc0ec7e035c3
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,21 @@ describe('EntryFieldsComponent', () => {
expect(component.showTimeInbuttons).toEqual(false);
});

fit('when a start hour is updated, but the entry is invalid, then do not dispatch UpdateActiveEntry', () => {
component.newData = mockEntryOverlap;
component.activeEntry = entry;
component.setDataToUpdate(entry);
const updatedTime = moment(mockDate).format('HH:mm');

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

component.onUpdateStartHour();

expect(store.dispatch).not.toHaveBeenCalled();
});

it(
'When start_time is updated, component.last_entry is equal to time entry in the position 1',
waitForAsync(() => {
Expand Down Expand Up @@ -309,19 +324,6 @@ describe('EntryFieldsComponent', () => {
expect(store.dispatch).toHaveBeenCalledTimes(1);
});

it('When start_time is updated for an invalid time entry. UpdateCurrentOrLastEntry action is NOT dispatched', () => {
component.newData = mockEntryOverlap;
component.activeEntry = entry;
component.setDataToUpdate(entry);
const updatedTime = moment(mockDate).subtract(4, 'hours').format('HH:mm');
component.entryForm.patchValue({ start_hour: updatedTime });
spyOn(store, 'dispatch');

component.onUpdateStartHour();

expect(store.dispatch).toHaveBeenCalledTimes(1);
});

it('when a technology is added or removed, then dispatch UpdateActiveEntry', () => {
const addedTechnologies = ['react'];
const isEntryFormValid = spyOn(component, 'entryFormIsValidate').and.returnValue(true);
Expand Down Expand Up @@ -586,18 +588,5 @@ describe('EntryFieldsComponent', () => {
expect(store.dispatch).not.toHaveBeenCalled();
});

it('do not display an error message when trying to updateStartHour, with no description and no ticket and it is an external app', () => {
component.newData = entry;
component.activeEntry = entry;
component.setDataToUpdate(entry);
spyOn(toastrServiceStub, 'error');

const hour = moment(mockDate).add(4, 'hour').format('HH:mm');
component.entryForm.patchValue({ start_hour: hour, description: '', uri: '', customer_name: 'Warby' });
component.onUpdateStartHour();

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

});

Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
this.actionSetDateSubscription.unsubscribe();
}

requiredFieldsForInternalAppExist(customerName, projectName) {
requiredFieldsForInternalAppExist(customerName: string, projectName: string) {
const emptyValue = '';
const areEmptyValues = [this.entryForm.value.uri, this.entryForm.value.description].every(
(item) => item === emptyValue
Expand Down