Skip to content

Commit 5a1ed1d

Browse files
committed
feat: TT-466 First commit for clockout frontend
1 parent 43ba25b commit 5a1ed1d

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/app/modules/time-clock/services/entry.service.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,12 @@ describe('EntryService', () => {
4040
});
4141

4242
it('loads an activeEntry with /running', () => {
43-
service.urlInProduction = true;
4443
service.loadActiveEntry().subscribe();
4544

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

50-
it('loads an activeEntry with /active/{userId}', () => {
51-
service.urlInProduction = false;
52-
service.loadActiveEntry().subscribe();
53-
54-
const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/active/2`);
55-
expect(loadEntryRequest.request.method).toBe('GET');
56-
});
57-
5849
it('loads summary with get /summary?time_offset=<time-offset>', () => {
5950
service.summary().subscribe();
6051
const timeOffset = new Date().getTimezoneOffset();
@@ -93,12 +84,21 @@ describe('EntryService', () => {
9384
});
9485

9586
it('stops an entry using POST', () => {
87+
service.urlInProduction = true;
9688
service.stopEntryRunning('id').subscribe();
9789

9890
const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/id/stop`);
9991
expect(updateEntryRequest.request.method).toBe('POST');
10092
});
10193

94+
it('stops an entry using PUT', () => {
95+
service.urlInProduction = false;
96+
service.stopEntryRunning('id').subscribe();
97+
98+
const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop`);
99+
expect(updateEntryRequest.request.method).toBe('PUT');
100+
});
101+
102102
it('when getting time entries for report, time range should be sent', () => {
103103
const yesterday = moment(new Date()).subtract(1, 'day');
104104
const today = moment(new Date());

src/app/modules/time-clock/services/entry.service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@ export class EntryService {
2222
urlInProduction = environment.production;
2323

2424
loadActiveEntry(): Observable<any> {
25-
let path = '';
26-
27-
if (this.urlInProduction){
28-
path = `${this.baseUrl}/running`;
29-
}else{
30-
path = `${this.baseUrl}/active/2`;
31-
}
32-
return this.http.get(path);
25+
return this.http.get(`${this.baseUrl}/running`);
3326
}
3427

3528
loadEntries(date): Observable<any> {
@@ -52,8 +45,15 @@ export class EntryService {
5245
}
5346

5447
stopEntryRunning(idEntry: string): Observable<any> {
55-
const url = `${this.baseUrl}/${idEntry}/stop`;
56-
return this.http.post(url, null);
48+
let path = '';
49+
50+
if (this.urlInProduction){
51+
path = `${this.baseUrl}/${idEntry}/stop`;
52+
return this.http.post(path, null);
53+
}else{
54+
path = `${this.baseUrl}/stop`;
55+
return this.http.put(path, null);
56+
}
5757
}
5858

5959
restartEntry(idEntry: string): Observable<Entry> {

0 commit comments

Comments
 (0)