Skip to content

Commit 2170c89

Browse files
scastillo-jpAngeluz-07
authored andcommitted
fix: #571 update async for waitForAsync
1 parent 6cff3df commit 2170c89

File tree

6 files changed

+51
-36
lines changed

6 files changed

+51
-36
lines changed

src/app/modules/shared/time-range-form/time-range.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ToastrService, IndividualConfig } from 'ngx-toastr';
2-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
33
import { MockStore, provideMockStore } from '@ngrx/store/testing';
44
import { TimeRangeFormComponent } from './time-range-form.component';
55
import { EntryState } from '../../time-clock/store/entry.reducer';
@@ -39,7 +39,7 @@ describe('Reports Page', () => {
3939
entriesForReport: [timeEntry],
4040
};
4141

42-
beforeEach(async(() => {
42+
beforeEach(waitForAsync(() => {
4343
TestBed.configureTestingModule({
4444
imports: [FormsModule, ReactiveFormsModule],
4545
declarations: [TimeRangeFormComponent, InputDateComponent],
Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
1-
{
2-
"data": [
1+
[
2+
{
3+
"id": 1,
4+
"name_technology": "Superman",
5+
"users": [
36
{
4-
"technology": [
7+
"id": 1,
8+
"email_user": "[email protected]",
9+
"time_spent": 10,
10+
"project": [
511
{
612
"id": 1,
7-
"name_technology": "Superman",
8-
"users": [
9-
{
10-
"id": 1,
11-
"email_user": "[email protected]",
12-
"time_spent": 10,
13-
"project": [
14-
{
15-
"id": "1",
16-
"project_name": "Time tracker",
17-
"time_spent": "8"
18-
}
19-
]
20-
}
21-
],
22-
"time_spent": 10
13+
"project_name": "Time tracker",
14+
"time_spent": 8
2315
}
2416
]
2517
}
26-
]
27-
}
18+
],
19+
"time_spent": 10
20+
},
21+
{
22+
"id": 2,
23+
"name_technology": "Tor",
24+
"users": [
25+
{
26+
"id": 1,
27+
"email_user": "[email protected]",
28+
"time_spent": 10,
29+
"project": [
30+
{
31+
"id": 1,
32+
"project_name": "Time tracker",
33+
"time_spent": 8
34+
}
35+
]
36+
}
37+
],
38+
"time_spent": 10
39+
}
40+
]

src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@
99
>
1010
<thead class="thead-blue">
1111
<tr class="d-flex">
12-
<th class="col md-col">User email</th>
13-
<th class="none" title="Duration (hours)">Time spend</th>
1412
<th class="none">Technology</th>
13+
<th class="none">Time spend</th>
1514
</tr>
1615
</thead>
1716
<app-loading-bar
1817
*ngIf="dataSource.isLoading"
1918
></app-loading-bar>
20-
<tbody *ngIf="!dataSource.isLoading">
19+
<tbody>
2120
<tr
2221
class="d-flex"
23-
*ngFor="let entry of dataSource.data"
22+
*ngFor="let data of technologies"
2423
>
25-
<td class="col md-col">{{ entry.owner_email }}</td>
26-
<td class="col lg-col">{{ entry.technologies }}</td>
27-
<td class="col sm-col">
28-
{{ entry.start_date | date: 'MM/dd/yyyy' }}
29-
</td>
24+
<td class="col md-col">{{ data.name_technology || '' }}</td>
25+
<td class="col lg-col">{{ data.time_spent || ''}}</td>
3026
</tr>
3127
</tbody>
3228
</table>

src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
1+
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
22
import { MockStore, provideMockStore } from '@ngrx/store/testing';
33
import { Entry } from 'src/app/modules/shared/models';
44
import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe';
@@ -35,7 +35,7 @@ describe('Reports Page', () => {
3535
}
3636
};
3737

38-
beforeEach(async(() => {
38+
beforeEach(waitForAsync(() => {
3939
TestBed.configureTestingModule({
4040
imports: [],
4141
declarations: [TechnologyReportTableComponent, SubstractDatePipe],
@@ -45,7 +45,7 @@ describe('Reports Page', () => {
4545

4646
}));
4747

48-
beforeEach(async(() => {
48+
beforeEach(waitForAsync(() => {
4949
fixture = TestBed.createComponent(TechnologyReportTableComponent);
5050
component = fixture.componentInstance;
5151
store.setState(state);

src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ import * as moment from 'moment';
66
import { Observable, Subject } from 'rxjs';
77
import { Entry } from 'src/app/modules/shared/models';
88
import { DataSource } from 'src/app/modules/shared/models/data-source.model';
9-
109
import { EntryState } from '../../../time-clock/store/entry.reducer';
1110
import { getReportDataSource } from '../../../time-clock/store/entry.selectors';
11+
import * as dataMock from './data.json';
1212

1313
@Component({
1414
selector: 'app-technology-report-table',
1515
templateUrl: './technology-report-table.component.html',
1616
styleUrls: ['./technology-report-table.component.scss']
1717
})
18+
1819
export class TechnologyReportTableComponent implements OnInit, OnDestroy, AfterViewInit {
20+
1921
dtOptions: any = {
2022
scrollY: '600px',
2123
paging: false,
@@ -64,14 +66,17 @@ export class TechnologyReportTableComponent implements OnInit, OnDestroy, AfterV
6466
isLoading$: Observable<boolean>;
6567
reportDataSource$: Observable<DataSource<Entry>>;
6668

69+
technologies: any = (dataMock as any).default;
6770
constructor(private store: Store<EntryState>) {
6871
this.reportDataSource$ = this.store.pipe(select(getReportDataSource));
6972
}
7073

74+
7175
ngOnInit(): void {
7276
this.reportDataSource$.subscribe((ds) => {
7377
this.rerenderDataTable();
7478
});
79+
console.log('data', dataMock);
7580
}
7681

7782
ngAfterViewInit(): void {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"moduleResolution": "node",
1212
"importHelpers": true,
1313
"target": "es2015",
14+
"resolveJsonModule": true,
1415
"allowSyntheticDefaultImports": false,
1516
"typeRoots": [
1617
"node_modules/@types"

0 commit comments

Comments
 (0)