Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions src/app/modules/time-clock/services/entry.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,21 @@ describe('EntryService', () => {
});

it('loads an activeEntry with /running', () => {
service.showOptionInDevelopment = true;
service.loadActiveEntry().subscribe();

const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/running`);
expect(loadEntryRequest.request.method).toBe('GET');
});

it('loads an activeEntry with /active/{userId}', () => {
service.showOptionInDevelopment = false;
service.loadActiveEntry().subscribe();

const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/active/2`);
expect(loadEntryRequest.request.method).toBe('GET');
});

it('loads summary with get /summary?time_offset=<time-offset>', () => {
service.summary().subscribe();
const timeOffset = new Date().getTimezoneOffset();
Expand Down
11 changes: 9 additions & 2 deletions src/app/modules/time-clock/services/entry.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TimeEntriesSummary } from '../models/time.entry.summary';
import { Injectable } from '@angular/core';
import { Injectable, Input } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { Observable } from 'rxjs';
Expand All @@ -19,9 +19,16 @@ export class EntryService {

static TIME_ENTRIES_DATE_TIME_FORMAT = 'yyyy-MM-ddTHH:mm:ssZZZZZ';
baseUrl = `${environment.timeTrackerApiUrl}/time-entries`;
@Input() showOptionInDevelopment: boolean;

loadActiveEntry(): Observable<any> {
return this.http.get(`${this.baseUrl}/running`);
let path = '';
if (this.showOptionInDevelopment){
path = `${this.baseUrl}/running`;
}else{
path = `${this.baseUrl}/active/2`;
}
return this.http.get(path);
}

loadEntries(date): Observable<any> {
Expand Down