Skip to content

Commit 19761b7

Browse files
fix: TTL-887 make changes according PR review
1 parent a6a76f3 commit 19761b7

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/app/modules/time-clock/pages/time-clock.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { EntryFieldsComponent } from '../components/entry-fields/entry-fields.co
1414
import { ToastrService } from 'ngx-toastr';
1515
import { LoginService } from '../../login/services/login.service';
1616
import { SocialAuthService } from 'angularx-social-login';
17+
import { dispatch } from 'rxjs/internal/observable/pairs';
1718

1819
describe('TimeClockComponent', () => {
1920
let component: TimeClockComponent;
@@ -152,12 +153,11 @@ describe('TimeClockComponent', () => {
152153
expect(store.dispatch).toHaveBeenCalledWith(new StopTimeEntryRunning('id'));
153154
});
154155

155-
it('clockOut set error Activity is required', () => {
156+
it('clockOut doesnt execute stopEntry() if entryFormIsValidate() returns false', () => {
156157
spyOn(store, 'dispatch');
157-
spyOn(injectedToastrService, 'error');
158158
spyOn(component.entryFieldsComponent, 'entryFormIsValidate').and.returnValue(false);
159159
component.clockOut();
160160

161-
expect(injectedToastrService.error).toHaveBeenCalled();
161+
expect(store.dispatch).not.toHaveBeenCalled();
162162
});
163163
});

src/app/modules/time-clock/pages/time-clock.component.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export class TimeClockComponent implements OnInit, OnDestroy {
4040
ngOnInit(): void {
4141
if (this.isProduction) {
4242
this.username = this.azureAdB2CService.isLogin() ? this.azureAdB2CService.getName() : '';
43-
}else{
44-
this.loginService.isLogin().subscribe(isLogin => {
43+
} else {
44+
this.loginService.isLogin().subscribe((isLogin) => {
4545
this.username = isLogin ? this.loginService.getName() : '';
4646
});
4747
}
@@ -57,14 +57,11 @@ export class TimeClockComponent implements OnInit, OnDestroy {
5757
}
5858

5959
reloadSummariesOnClockOut() {
60-
this.clockOutSubscription = this.actionsSubject$.pipe(
61-
filter((action) => (
62-
action.type === EntryActionTypes.STOP_TIME_ENTRY_RUNNING_SUCCESS
63-
)
64-
)
65-
).subscribe( (action) => {
66-
this.store.dispatch(new LoadEntriesSummary());
67-
});
60+
this.clockOutSubscription = this.actionsSubject$
61+
.pipe(filter((action) => action.type === EntryActionTypes.STOP_TIME_ENTRY_RUNNING_SUCCESS))
62+
.subscribe((action) => {
63+
this.store.dispatch(new LoadEntriesSummary());
64+
});
6865
}
6966

7067
stopEntry() {
@@ -75,16 +72,11 @@ export class TimeClockComponent implements OnInit, OnDestroy {
7572
clockOut() {
7673
if (this.entryFieldsComponent.entryFormIsValidate()) {
7774
this.stopEntry();
78-
} else {
79-
this.entryFieldsComponent.entryForm.get('activity_id').markAsTouched();
8075
}
8176
}
8277

8378
ngOnDestroy(): void {
8479
this.clockOutSubscription.unsubscribe();
8580
this.storeSubscription.unsubscribe();
8681
}
87-
8882
}
89-
90-

0 commit comments

Comments
 (0)