Skip to content

Commit 88f1a3c

Browse files
author
Edgar Guaman
committed
refactor: TT-304 Handle message: Editing methods and unit tests associated
1 parent 2437144 commit 88f1a3c

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/app/modules/time-entries/pages/time-entries.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
<th class="col"></th>
5555
</tr>
5656
</thead>
57-
<tr *ngIf="checkIfDataSourceIsLoading(dataSource)">
57+
<tr *ngIf="checkIfDataSourceIsLoadingorEmpty(dataSource)">
5858
<td class="text-center" colspan="7">{{NO_DATA_MESSAGE}}</td>
5959
</tr>
6060
<app-loading-bar *ngIf="dataSource.isLoading"></app-loading-bar>
6161
<tbody *ngIf="!dataSource.isLoading">
62-
<tr *ngIf="checkIfDataSourceIsEmpty(dataSource)">
62+
<tr *ngIf="checkIfDataSourceIsLoadingorEmpty(dataSource)">
6363
<td class="text-center" colspan="7">{{NO_DATA_MESSAGE}}</td>
6464
</tr>
6565
<tr class="d-flex" *ngFor="let entry of dataSource.data">

src/app/modules/time-entries/pages/time-entries.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,22 +670,22 @@ describe('TimeEntriesComponent', () => {
670670
});
671671

672672
it('checkIfDataSourceIsLoading should be false when dataSource.isLoading is false', () => {
673-
expect(component.checkIfDataSourceIsLoading(state.timeEntriesDataSource)).toBeFalse();
673+
expect(component.checkIfDataSourceIsLoadingorEmpty(state.timeEntriesDataSource)).toBeFalse();
674674
});
675675

676676
it('checkIfDataSourceIsLoading should be true when dataSource.isLoading is true', () => {
677677
state.timeEntriesDataSource.isLoading = true;
678678

679-
expect(component.checkIfDataSourceIsLoading(state.timeEntriesDataSource)).toBeTrue();
679+
expect(component.checkIfDataSourceIsLoadingorEmpty(state.timeEntriesDataSource)).toBeTrue();
680680
});
681681

682682
it('checkIfDataSourceIsEmpty should be false when dataSource.data.length is not empty', () => {
683-
expect(component.checkIfDataSourceIsEmpty(state.timeEntriesDataSource)).toBeFalse();
683+
expect(component.checkIfDataSourceIsLoadingorEmpty(state.timeEntriesDataSource)).toBeFalse();
684684
});
685685

686686
it('checkIfDataSourceIsEmpty should be true when dataSource.data.length is empty', () => {
687687
state.timeEntriesDataSource.data = [];
688688

689-
expect(component.checkIfDataSourceIsEmpty(state.timeEntriesDataSource)).toBeTrue();
689+
expect(component.checkIfDataSourceIsLoadingorEmpty(state.timeEntriesDataSource)).toBeTrue();
690690
});
691691
});

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,8 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
219219
}
220220
}
221221

222-
checkIfDataSourceIsLoading(data: DataSource<Entry>): boolean {
223-
if (data.isLoading) {
224-
return true;
225-
}
226-
return false;
227-
}
228-
229-
checkIfDataSourceIsEmpty(data: DataSource<Entry>): boolean {
230-
if (data.data.length === 0) {
222+
checkIfDataSourceIsLoadingorEmpty(source?: DataSource<Entry>): boolean {
223+
if (source.isLoading || source.data.length === 0) {
231224
return true;
232225
}
233226
return false;

0 commit comments

Comments
 (0)