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
style: #204 Improving code readability by removing dead code
  • Loading branch information
Juan Gabriel Guzman committed May 29, 2020
commit f53182565d09107b31c487eccdac8e3c165c9de4
26 changes: 10 additions & 16 deletions src/app/modules/time-clock/services/entry.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {TestBed, inject} from '@angular/core/testing';
import {inject, TestBed} from '@angular/core/testing';

import {EntryService} from './entry.service';
import {NewEntry} from '../../shared/models';
Expand All @@ -17,7 +17,6 @@ describe('EntryService', () => {
httpMock = TestBed.inject(HttpTestingController);
datePipe = TestBed.inject(DatePipe);
service.baseUrl = 'time-entries';

});

it('services are ready to be used', inject(
Expand All @@ -42,24 +41,21 @@ describe('EntryService', () => {
});

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

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

it('loads summary with get /summary', () => {
service.summary().subscribe((response) => {
});
service.summary().subscribe();

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

it('loads all Entries', () => {
service.loadEntries(new Date().getMonth).subscribe((response) => {
});
it('load all Entries', () => {
service.loadEntries(new Date().getMonth).subscribe();

const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}`);
expect(loadEntryRequest.request.method).toBe('GET');
Expand All @@ -69,25 +65,23 @@ describe('EntryService', () => {
it('update an entry using PUT', () => {
const updatedEntry = {foo: 'bar', id: 'id'};

service.updateActiveEntry(updatedEntry).subscribe((response) => {

});
service.updateActiveEntry(updatedEntry).subscribe();

const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/id`);
expect(updateEntryRequest.request.method).toBe('PUT');
});

it('delete an entry using DELETE', () => {
const entry = 'entryId';
service.deleteEntry(entry).subscribe((response) => {
});

service.deleteEntry(entry).subscribe();

const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/${entry}`);
expect(updateEntryRequest.request.method).toBe('DELETE');
});

it('stops an entry using POST', () => {
service.stopEntryRunning('id').subscribe((response) => {
});
service.stopEntryRunning('id').subscribe();

const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/id/stop`);
expect(updateEntryRequest.request.method).toBe('POST');
Expand Down
10 changes: 5 additions & 5 deletions src/app/modules/time-clock/services/entry.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TimeEntriesSummary } from '../models/time.entry.summary';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {TimeEntriesSummary} from '../models/time.entry.summary';
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';

import { Observable } from 'rxjs';
import { environment } from './../../../../environments/environment';
import {Observable} from 'rxjs';
import {environment} from './../../../../environments/environment';
import {TimeEntriesTimeRange} from '../models/time-entries-time-range';
import {DatePipe} from '@angular/common';

Expand Down