Skip to content

Commit 2aa8b76

Browse files
author
Juan Gabriel Guzman
committed
feat: #310 Fixing some unit tests
1 parent 98c65c0 commit 2aa8b76

File tree

12 files changed

+68
-83
lines changed

12 files changed

+68
-83
lines changed

src/app/modules/activities-management/components/activity-list/activity-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="activity-list">
22
<table class="table table-sm table-bordered table-striped">
3-
<thead class="thead-orange">
3+
<thead class="thead-blue">
44
<tr class="d-flex">
55
<th class="col-9">Activity</th>
66
<th class="col-3 text-center"></th>

src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<table *ngIf="customers" class="table table-sm table-bordered table-striped mb-0" datatable [dtTrigger]="dtTrigger" [dtOptions]="dtOptions">
2-
<thead class="thead-orange">
2+
<thead class="thead-blue">
33
<tr class="d-flex">
44
<th class="col-9">Name</th>
55
<th class="col-3 text-center">Options</th>

src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="project-type-list-div">
22
<table class="table table-sm table-bordered table-striped">
3-
<thead class="thead-orange">
3+
<thead class="thead-blue">
44
<tr class="d-flex">
55
<th class="col-9">Project type</th>
66
<th class="col-3 text-center"></th>

src/app/modules/customer-management/components/projects/components/project-list/project-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="project-list">
22
<table class="table table-sm table-bordered table-striped">
3-
<thead class="thead-orange">
3+
<thead class="thead-blue">
44
<tr class="d-flex">
55
<th class="col-9">Project</th>
66
<th class="col-3 text-center"></th>
Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
<div class="container-flex m-5">
2-
<table class="table table-sm table-striped mb-0" datatable [dtTrigger]="dtTrigger" [dtOptions]="dtOptions">
3-
<thead class="thead-orange">
4-
<tr class="d-flex">
5-
<th class="col md-col">Date</th>
6-
<th class="col sm-col">Duration</th>
7-
<th class="col md-col">Project</th>
8-
<th class="col md-col">Ticket</th>
9-
<th class="col lg-col" >Description</th>
10-
<th class="col lg-col">Technologies</th>
11-
</tr>
12-
</thead>
13-
<tbody>
14-
<tr
15-
class="d-flex"
16-
*ngFor="let entry of data"
17-
>
18-
<td class="col md-col"> {{ entry.start_date | date: 'dd/MM/yyyy' }} </td>
19-
<td class="col sm-col"> {{ entry.end_date | substractDate: entry.start_date }} </td>
20-
<td class="col md-col"> {{ entry.project_name }} </td>
21-
<td class="col md-col"> {{ entry.uri }} </td>
22-
<td class="col lg-col multiline-col"> {{ entry.description }} </td>
23-
<td class="col lg-col multiline-col"> {{ entry.technologies }} </td>
24-
</tr>
25-
</tbody>
26-
</table>
1+
<div class="row mt-5">
2+
<div class="col">
3+
<table class="table table-sm table-striped" datatable [dtTrigger]="dtTrigger" [dtOptions]="dtOptions">
4+
<thead class="thead-blue">
5+
<tr class="d-flex">
6+
<th class="col md-col">Date</th>
7+
<th class="col sm-col">Duration</th>
8+
<th class="col md-col">Project</th>
9+
<th class="col md-col">Ticket</th>
10+
<th class="col lg-col">Description</th>
11+
<th class="col lg-col">Technologies</th>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
<tr
16+
class="d-flex"
17+
*ngFor="let entry of data"
18+
>
19+
<td class="col md-col"> {{ entry.start_date | date: 'dd/MM/yyyy' }} </td>
20+
<td class="col sm-col"> {{ entry.end_date | substractDate: entry.start_date }} </td>
21+
<td class="col md-col"> {{ entry.project_name }} </td>
22+
<td class="col md-col"> {{ entry.uri }} </td>
23+
<td class="col lg-col multiline-col"> {{ entry.description }} </td>
24+
<td class="col lg-col multiline-col"> {{ entry.technologies }} </td>
25+
</tr>
26+
</tbody>
27+
</table>
28+
</div>
2729
</div>

src/app/modules/reports/components/time-entries-table/time-entries-table.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
}
88

99
.lg-col{
10-
min-width: 20em;
10+
width: 15em;
1111
}
1212

1313
.multiline-col{
Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
<div class="container-flex">
2-
<form [formGroup]="reportForm" (ngSubmit)="onSubmit()">
3-
<div class="row">
4-
<div class="col">
5-
<div class="input-group">
6-
<app-input-label text="Start Date"></app-input-label>
7-
<app-input-date formControlName="startDate" required="true"></app-input-date>
8-
</div>
9-
</div>
10-
<div class="col">
11-
<div class="input-group">
12-
<app-input-label text="End Date"></app-input-label>
13-
<app-input-date formControlName="endDate" required="true"></app-input-date>
14-
</div>
1+
<form [formGroup]="reportForm" (ngSubmit)="onSubmit()">
2+
<div class="row">
3+
<div class="col">
4+
<div class="input-group">
5+
<app-input-label text="Start Date"></app-input-label>
6+
<app-input-date formControlName="startDate" required="true"></app-input-date>
157
</div>
168
</div>
17-
<div class="row">
18-
<div class="col">
19-
<button type="submit" class="btn btn-primary float-right"
20-
[disabled]="!(reportForm.touched && reportForm.valid)">Search
21-
</button>
9+
<div class="col">
10+
<div class="input-group">
11+
<app-input-label text="End Date"></app-input-label>
12+
<app-input-date formControlName="endDate" required="true"></app-input-date>
2213
</div>
2314
</div>
24-
</form>
25-
</div>
15+
</div>
16+
<div class="row mt-3">
17+
<div class="col">
18+
<button type="submit" class="btn btn-primary float-right"
19+
[disabled]="!(reportForm.touched && reportForm.valid)">Search
20+
</button>
21+
</div>
22+
</div>
23+
</form>
24+
2625

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<div class="w-100">
2-
<app-time-range-form></app-time-range-form>
3-
<app-time-entries-table></app-time-entries-table>
4-
</div>
1+
<app-time-range-form></app-time-range-form>
2+
<app-time-entries-table></app-time-entries-table>
3+

src/app/modules/reports/pages/reports.component.spec.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@ describe('ReportsComponent', () => {
66
let component: ReportsComponent;
77
let fixture: ComponentFixture<ReportsComponent>;
88

9-
function setup() {
10-
// tslint:disable-next-line: no-shadowed-variable
11-
const fixture = TestBed.createComponent(ReportsComponent);
12-
const app = fixture.debugElement.componentInstance;
13-
return { fixture, app };
14-
}
15-
169
beforeEach(async(() => {
1710
TestBed.configureTestingModule({
1811
declarations: [ReportsComponent],
1912
}).compileComponents();
13+
fixture = TestBed.createComponent(ReportsComponent);
2014
}));
2115

2216
beforeEach(() => {
@@ -30,16 +24,11 @@ describe('ReportsComponent', () => {
3024
});
3125

3226
it('should have form and datatable components', async(() => {
33-
// tslint:disable-next-line: no-shadowed-variable
34-
const { fixture } = setup();
35-
3627
fixture.detectChanges();
3728

3829
const compile = fixture.debugElement.nativeElement;
39-
const div = compile.querySelector('div');
4030
const reportForm = compile.querySelector('app-time-range-form');
4131
const reportDataTable = compile.querySelector('app-time-entries-table');
42-
expect(div).toBeTruthy();
4332
expect(reportForm).toBeTruthy();
4433
expect(reportDataTable).toBeTruthy();
4534
}));

src/app/modules/time-clock/store/entry.effects.spec.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {TestBed} from '@angular/core/testing';
22
import {provideMockActions} from '@ngrx/effects/testing';
33
import {EntryEffects} from './entry.effects';
4-
import {Observable, of} from 'rxjs';
4+
import {Observable, of, throwError} from 'rxjs';
55
import {HttpClientTestingModule} from '@angular/common/http/testing';
66
import {ToastrModule} from 'ngx-toastr';
77
import {Action} from '@ngrx/store';
@@ -34,7 +34,7 @@ describe('TimeEntryActionEffects', () => {
3434
expect(effects).toBeTruthy();
3535
});
3636

37-
it('When the service returns a value, then LOAD_ENTRIES_BY_TIME_RANGE_SUCCESS should be triggered', async () => {
37+
it('When the service returns a value, then LOAD_ENTRIES_BY_TIME_RANGE_SUCCESS should be triggered', () => {
3838
const timeRange: TimeEntriesTimeRange = {start_date: new Date(), end_date: new Date()};
3939
actions$ = of({type: EntryActionTypes.LOAD_ENTRIES_BY_TIME_RANGE, timeRange});
4040
const serviceSpy = spyOn(service, 'loadEntriesByTimeRange');
@@ -44,20 +44,16 @@ describe('TimeEntryActionEffects', () => {
4444
expect(action.type).toEqual(EntryActionTypes.LOAD_ENTRIES_BY_TIME_RANGE_SUCCESS);
4545
});
4646

47-
expect(service.loadEntriesByTimeRange).toHaveBeenCalledWith(timeRange);
4847
});
4948

5049
it('When the service fails, then LOAD_ENTRIES_BY_TIME_RANGE_FAIL should be triggered', async () => {
51-
const timeRange: TimeEntriesTimeRange = {start_date: new Date(), end_date: new Date()};
52-
actions$ = of({type: EntryActionTypes.LOAD_ENTRIES_BY_TIME_RANGE, timeRange});
53-
const serviceSpy = spyOn(service, 'loadEntriesByTimeRange');
54-
serviceSpy.and.throwError('error getting time entries');
55-
56-
effects.loadEntriesByTimeRange$.subscribe(action => {
57-
expect(action.type).toEqual(EntryActionTypes.LOAD_ENTRIES_BY_TIME_RANGE_FAIL);
58-
});
50+
const timeRange: TimeEntriesTimeRange = {start_date: new Date(), end_date: new Date()};
51+
actions$ = of({type: EntryActionTypes.LOAD_ENTRIES_BY_TIME_RANGE, timeRange});
52+
spyOn(service, 'loadEntriesByTimeRange').and.returnValue(throwError('any error'));
5953

60-
expect(service.loadEntriesByTimeRange).toHaveBeenCalledWith(timeRange);
54+
effects.loadEntriesByTimeRange$.subscribe(action => {
55+
expect(action.type).toEqual(EntryActionTypes.LOAD_ENTRIES_BY_TIME_RANGE_FAIL);
56+
});
6157
});
6258

6359
// TODO Implement the remaining unit tests for the other effects.

0 commit comments

Comments
 (0)