Skip to content

Commit b927d96

Browse files
author
Edgar Guaman
committed
refactor: TT-304 Handle message: Rewriting method and unit tests for that method
1 parent 88f1a3c commit b927d96

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
</tr>
6060
<app-loading-bar *ngIf="dataSource.isLoading"></app-loading-bar>
6161
<tbody *ngIf="!dataSource.isLoading">
62-
<tr *ngIf="checkIfDataSourceIsLoadingorEmpty(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: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -669,23 +669,13 @@ describe('TimeEntriesComponent', () => {
669669
expect(HTMLTimeEntriesView).not.toBeNull();
670670
});
671671

672-
it('checkIfDataSourceIsLoading should be false when dataSource.isLoading is false', () => {
673-
expect(component.checkIfDataSourceIsLoadingorEmpty(state.timeEntriesDataSource)).toBeFalse();
674-
});
675-
676-
it('checkIfDataSourceIsLoading should be true when dataSource.isLoading is true', () => {
672+
it('checkIfDataSourceIsLoadingorEmpty should be true when dataSource is Loading and data is not empty', () => {
677673
state.timeEntriesDataSource.isLoading = true;
678-
674+
state.timeEntriesDataSource.data = [];
679675
expect(component.checkIfDataSourceIsLoadingorEmpty(state.timeEntriesDataSource)).toBeTrue();
680676
});
681677

682-
it('checkIfDataSourceIsEmpty should be false when dataSource.data.length is not empty', () => {
678+
it('checkIfDataSourceIsLoadingorEmpty should be false when just dataSource.data.length is empty', () => {
683679
expect(component.checkIfDataSourceIsLoadingorEmpty(state.timeEntriesDataSource)).toBeFalse();
684680
});
685-
686-
it('checkIfDataSourceIsEmpty should be true when dataSource.data.length is empty', () => {
687-
state.timeEntriesDataSource.data = [];
688-
689-
expect(component.checkIfDataSourceIsLoadingorEmpty(state.timeEntriesDataSource)).toBeTrue();
690-
});
691681
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
220220
}
221221

222222
checkIfDataSourceIsLoadingorEmpty(source?: DataSource<Entry>): boolean {
223-
if (source.isLoading || source.data.length === 0) {
223+
if (source.isLoading && source.data.length === 0) {
224224
return true;
225225
}
226226
return false;

0 commit comments

Comments
 (0)