Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 24 additions & 2 deletions src/app/modules/time-entries/pages/time-entries.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import { TechnologyState } from '../../shared/store/technology.reducers';
import { TimeEntriesSummaryComponent } from '../../time-clock/components/time-entries-summary/time-entries-summary.component';
import * as entryActions from '../../time-clock/store/entry.actions';
import { EntryState } from '../../time-clock/store/entry.reducer';
import { getTimeEntriesDataSource } from '../../time-clock/store/entry.selectors';
import { getTimeEntriesDataSource, getActiveTimeEntry } from '../../time-clock/store/entry.selectors';
import { LoadActiveEntry } from './../../time-clock/store/entry.actions';
import { TimeEntriesComponent } from './time-entries.component';

import { ActionsSubject } from '@ngrx/store';
import { EntryActionTypes } from './../../time-clock/store/entry.actions';

describe('TimeEntriesComponent', () => {
type Merged = TechnologyState & ProjectState & EntryState;
Expand Down Expand Up @@ -179,6 +180,27 @@ describe('TimeEntriesComponent', () => {
expect(component.entryId).toBe(anEntryId);
});

it('when trigger edit action and there is no active entry, active entry should be null', () => {
state.active = null;
mockEntriesSelector = store.overrideSelector(getActiveTimeEntry, state.active);

const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject;
const action = {
type: EntryActionTypes.UPDATE_ENTRY_SUCCESS,
payload: {
project_id: 'project-id',
start_date: '2010-05-05T10:04',
description: 'description',
technologies: [],
uri: 'abc',
},
};

actionSubject.next(action);

expect(component.activeTimeEntry).toBeNull();
});

it('given a list of entries having an entry running when editing a different entry it cannot be marked as WIP ', () => {
const anEntryId = '1';
const anotherEntryId = '2';
Expand Down
5 changes: 2 additions & 3 deletions src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
)
)
).subscribe((action) => {
this.loadActiveEntry();
this.store.dispatch(new entryActions.LoadEntries(new Date().getMonth() + 1));
});
}
Expand Down Expand Up @@ -124,9 +125,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
loadActiveEntry() {
this.store.dispatch(new entryActions.LoadActiveEntry());
this.store.pipe(select(getActiveTimeEntry)).subscribe((activeTimeEntry) => {
if (activeTimeEntry) {
this.activeTimeEntry = activeTimeEntry;
}
this.activeTimeEntry = activeTimeEntry;
});
}

Expand Down