From 54ee776d87a6a80f3a292eb8403ec9455831cb62 Mon Sep 17 00:00:00 2001 From: Jimmy Jaramillo Date: Tue, 23 Aug 2022 17:19:04 -0500 Subject: [PATCH] TTA-141: fixing eslint and remove code unnecessary --- src/app/modules/login/login.component.spec.ts | 2 +- src/app/modules/login/login.component.ts | 10 +++++----- .../modules/login/services/login.service.spec.ts | 14 ++++++-------- .../time-entries-table.component.spec.ts | 6 +++--- .../time-entries-table.component.ts | 4 ++-- .../time-clock/pages/time-clock.component.ts | 2 +- .../modules/time-clock/services/entry.service.ts | 3 ++- src/app/modules/time-clock/store/entry.reducer.ts | 2 +- .../time-clock/store/entry.selectors.spec.ts | 2 +- .../user/services/user-info.service.spec.ts | 6 +++--- 10 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/app/modules/login/login.component.spec.ts b/src/app/modules/login/login.component.spec.ts index 46ed1537f..5344d0620 100644 --- a/src/app/modules/login/login.component.spec.ts +++ b/src/app/modules/login/login.component.spec.ts @@ -49,7 +49,7 @@ describe('LoginComponent', () => { id: 'user_id', tenant_id: 'tenant_test', deleted: 'no', - } + }; const featureToggleCookiesServiceStub = { setCookies() { diff --git a/src/app/modules/login/login.component.ts b/src/app/modules/login/login.component.ts index 0c6493947..30cb8c6e8 100644 --- a/src/app/modules/login/login.component.ts +++ b/src/app/modules/login/login.component.ts @@ -50,14 +50,14 @@ export class LoginComponent implements OnInit { this.azureAdB2CService.signIn().subscribe(() => { this.featureToggleCookiesService.setCookies(); this.azureAdB2CService.setCookies(); - const userId = this.azureAdB2CService.getUserId() + const userId = this.azureAdB2CService.getUserId(); this.userService.loadUser(userId).subscribe((user) => { - const user_groups = { + const userGroups = { groups: user.groups - } - this.loginService.setLocalStorage('user', JSON.stringify(user_groups)); + }; + this.loginService.setLocalStorage('user', JSON.stringify(userGroups)); this.router.navigate(['']); - }) + }); }); } } diff --git a/src/app/modules/login/services/login.service.spec.ts b/src/app/modules/login/services/login.service.spec.ts index 0c49c0e6a..d2f446f76 100644 --- a/src/app/modules/login/services/login.service.spec.ts +++ b/src/app/modules/login/services/login.service.spec.ts @@ -1,5 +1,5 @@ import { HttpClient } from '@angular/common/http'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; import { JwtHelperService } from '@auth0/angular-jwt'; import { SocialAuthService } from 'angularx-social-login'; @@ -10,7 +10,6 @@ import { LoginService } from './login.service'; describe('LoginService', () => { let service: LoginService; - let httpMock: HttpTestingController; let cookieService: CookieService; let socialAuthService: SocialAuthService; let account; @@ -33,7 +32,6 @@ describe('LoginService', () => { }); service = TestBed.inject(LoginService); cookieService = TestBed.inject(CookieService); - httpMock = TestBed.inject(HttpTestingController); socialAuthService = TestBed.inject(SocialAuthService); account = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6ImFiYyIsIm5hbWUiOiJhYmMiLCJlbWFpbCI6ImFiYyIsImdyb3VwcyI6WyJhYmMiXX0.UNxyDT8XzXJhI1F3LySBU7TJlpENPUPHj8my7Obw2ZM'; let store = {}; @@ -94,14 +92,14 @@ describe('LoginService', () => { }); it('load a user by sending a token using POST', () => { - const token = 'test_123' + const token = 'test_123'; service.baseUrl = '/users'; const mockSuccessDataPost = { SUCCESS: true, data: {} - } + }; httpClientSpy.post.and.returnValue(of(mockSuccessDataPost)); - service.getUser('token').subscribe(); + service.getUser(token).subscribe(); expect(httpClientSpy.post).toHaveBeenCalled(); }); @@ -161,12 +159,12 @@ describe('LoginService', () => { it('should call setLocalStorage when there is a new_token ', () => { spyOn(cookieService, 'check').and.returnValue(true); spyOn(service, 'setLocalStorage'); - const token = 'test123' + const token = 'test123'; service.baseUrl = '/users'; const mockSuccessDataPost = { SUCCESS: true, new_token: 'test_token' - } + }; httpClientSpy.post.and.returnValue(of(mockSuccessDataPost)); service.isValidToken(token).subscribe(); expect(service.setLocalStorage).toHaveBeenCalled(); diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts index 6e84b0fc8..01f49ae06 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts @@ -212,10 +212,10 @@ describe('Reports Page', () => { it('the sume of hours of entries selected is equal to {hours:0, minutes:0, seconds:0}', () => { let checked = true; - let {hours, minutes, seconds}:TotalHours = component.sumHoursEntriesSelected(timeEntryList[0], checked); + let {hours, minutes, seconds}: TotalHours = component.sumHoursEntriesSelected(timeEntryList[0], checked); checked = false; - ({hours, minutes,seconds} = component.sumHoursEntriesSelected(timeEntryList[0], checked)); - expect({hours, minutes, seconds}).toEqual({hours:0, minutes:0, seconds:0}); + ({hours, minutes, seconds} = component.sumHoursEntriesSelected(timeEntryList[0], checked)); + expect({hours, minutes, seconds}).toEqual({hours: 0, minutes: 0, seconds: 0}); }); it('should export data with the correct format', () => { diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts index 7709e94a7..5dc201222 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts @@ -69,7 +69,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn }, ], columnDefs: [{ type: 'date', targets: 2}, {orderable: false, targets: [0]}], - order: [[1,'asc'],[2,'desc'],[4,'desc']] + order: [[1, 'asc'], [2, 'desc'], [4, 'desc']] }; dtTrigger: Subject = new Subject(); @ViewChild(DataTableDirective, { static: false }) @@ -79,7 +79,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn rerenderTableSubscription: Subscription; resultSum: TotalHours; resultSumEntriesSelected: TotalHours; - resultSumEntriesSelected$:Observable; + resultSumEntriesSelected$: Observable; totalHoursSubscription: Subscription; dateTimeOffset: ParseDateTimeOffset; diff --git a/src/app/modules/time-clock/pages/time-clock.component.ts b/src/app/modules/time-clock/pages/time-clock.component.ts index c24f2b6ca..42078d5f3 100644 --- a/src/app/modules/time-clock/pages/time-clock.component.ts +++ b/src/app/modules/time-clock/pages/time-clock.component.ts @@ -43,7 +43,7 @@ export class TimeClockComponent implements OnInit, OnDestroy { }else{ this.loginService.isLogin().subscribe(isLogin => { this.username = isLogin ? this.loginService.getName() : ''; - }) + }); } this.storeSubscription = this.store.pipe(select(getActiveTimeEntry)).subscribe((activeTimeEntry) => { this.activeTimeEntry = activeTimeEntry; diff --git a/src/app/modules/time-clock/services/entry.service.ts b/src/app/modules/time-clock/services/entry.service.ts index 125041202..e8b9a1b63 100644 --- a/src/app/modules/time-clock/services/entry.service.ts +++ b/src/app/modules/time-clock/services/entry.service.ts @@ -46,7 +46,8 @@ export class EntryService { } stopEntryRunning(idEntry: string): Observable { - return (this.urlInProductionLegacy ? this.http.post(`${this.baseUrl}/${idEntry}/stop`, null) : this.http.put(`${this.baseUrl}/stop`, null) ); + return (this.urlInProductionLegacy ? + this.http.post(`${this.baseUrl}/${idEntry}/stop`, null) : this.http.put(`${this.baseUrl}/stop`, null) ); } restartEntry(idEntry: string): Observable { diff --git a/src/app/modules/time-clock/store/entry.reducer.ts b/src/app/modules/time-clock/store/entry.reducer.ts index d3af715f8..023328efb 100644 --- a/src/app/modules/time-clock/store/entry.reducer.ts +++ b/src/app/modules/time-clock/store/entry.reducer.ts @@ -266,7 +266,7 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi return { ...state, isLoading: true, - resultSumEntriesSelected:{hours:0, minutes:0, seconds:0}, + resultSumEntriesSelected: {hours: 0, minutes: 0, seconds: 0}, reportDataSource: { data: [], isLoading: true diff --git a/src/app/modules/time-clock/store/entry.selectors.spec.ts b/src/app/modules/time-clock/store/entry.selectors.spec.ts index 06c3c02e2..1d5c088c0 100644 --- a/src/app/modules/time-clock/store/entry.selectors.spec.ts +++ b/src/app/modules/time-clock/store/entry.selectors.spec.ts @@ -55,7 +55,7 @@ describe('Entry selectors', () => { }); it('should select resultSumEntriesSelected', () => { - const resultSumEntriesSelected:TotalHours = { hours:0, minutes:0, seconds:0 }; + const resultSumEntriesSelected: TotalHours = { hours: 0, minutes: 0, seconds: 0 }; const entryState = { resultSumEntriesSelected }; expect(selectors.getResultSumEntriesSelected.projector(entryState)).toEqual(resultSumEntriesSelected); diff --git a/src/app/modules/user/services/user-info.service.spec.ts b/src/app/modules/user/services/user-info.service.spec.ts index a366ab018..04f17c586 100644 --- a/src/app/modules/user/services/user-info.service.spec.ts +++ b/src/app/modules/user/services/user-info.service.spec.ts @@ -79,9 +79,9 @@ describe('UserInfoService', () => { const groupsTT = {groups: ['fake-admin', 'fake-admin-tt']}; spyOn(mockLoginService, 'getLocalStorage').and.returnValue(JSON.stringify(groupsTT)); service.isLegacyProduction = true; - service.isMemberOf('fake-admin').subscribe((value) => { - expect(value).toEqual(true); - }); + service.isMemberOf('fake-admin').subscribe((value) => { + expect(value).toEqual(true); + }); }); });