Skip to content

Commit 9888ebb

Browse files
authored
fix: tests (#982)
* fix: tests
1 parent 542fdc4 commit 9888ebb

File tree

5 files changed

+11
-35
lines changed

5 files changed

+11
-35
lines changed

src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('ProjectService', () => {
7474
service.getRecentProjects().subscribe((projectsInResponse) => {
7575
expect(projectsInResponse.length).toBe(projectsFoundSize);
7676
});
77-
const getProjectsRequest = httpMock.expectOne(`${service.url}/recent`);
77+
const getProjectsRequest = httpMock.expectOne(`${service.url}/recent/`);
7878
expect(getProjectsRequest.request.method).toBe('GET');
7979
getProjectsRequest.flush(projectsList);
8080
});

src/app/modules/customer-management/components/projects/components/store/project.effects.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ProjectActionTypes } from './project.actions';
88
import { ProjectEffects } from './project.effects';
99
import { HttpClientTestingModule } from '@angular/common/http/testing';
1010
import { ToastrModule, ToastrService } from 'ngx-toastr';
11-
import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY } from '../../../../../shared/messages';
11+
import { INFO_SAVED_SUCCESSFULLY, PROJECT_DEACTIVATED_SUCCESSFULLY } from '../../../../../shared/messages';
1212

1313
describe('ProjectEffects', () => {
1414
let actions$: Observable<Action>;
@@ -128,7 +128,7 @@ describe('ProjectEffects', () => {
128128
spyOn(service, 'deleteProject').and.returnValue(of({}));
129129

130130
effects.deleteProject$.subscribe((action) => {
131-
expect(toastrService.success).toHaveBeenCalledWith(INFO_DELETE_SUCCESSFULLY);
131+
expect(toastrService.success).toHaveBeenCalledWith(PROJECT_DEACTIVATED_SUCCESSFULLY);
132132
expect(action.type).toEqual(ProjectActionTypes.DELETE_PROJECT_SUCCESS);
133133
});
134134
});

src/app/modules/shared/interceptors/inject.token.interceptor.spec.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,4 @@ describe('InjectTokenInterceptor test', () => {
3232
expect(handler.handle).toHaveBeenCalledWith(request);
3333
});
3434

35-
it('if request.url is part of time-tracker-api, then Authorization header is injected', () => {
36-
const interceptor = new InjectTokenInterceptor(azureAdB2CService, loginService);
37-
interceptor.isProduction = true;
38-
const request = new HttpRequest('GET', environment.timeTrackerApiUrl);
39-
spyOn(handler, 'handle');
40-
const requestWithHeaders = request.clone(
41-
{
42-
headers: request.headers.set('Authorization', 'Bearer XYZ')
43-
});
44-
45-
interceptor.intercept(request, handler);
46-
47-
expect(handler.handle).toHaveBeenCalledWith(requestWithHeaders);
48-
});
49-
5035
});

src/app/modules/time-clock/services/entry.service.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('EntryService', () => {
1717
service = TestBed.inject(EntryService);
1818
httpMock = TestBed.inject(HttpTestingController);
1919
service.baseUrl = 'time-entries';
20-
reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report';
20+
reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report/';
2121
});
2222

2323
it('services are ready to be used', inject(
@@ -36,22 +36,22 @@ describe('EntryService', () => {
3636
expect(response.length).toBe(1);
3737
});
3838

39-
const createEntryRequest = httpMock.expectOne(service.baseUrl);
39+
const createEntryRequest = httpMock.expectOne(`${service.baseUrl}/`);
4040
expect(createEntryRequest.request.method).toBe('POST');
4141
createEntryRequest.flush(entry);
4242
});
4343

4444
it('loads an activeEntry with /running', () => {
4545
service.loadActiveEntry().subscribe();
4646

47-
const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/running`);
47+
const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/running/`);
4848
expect(loadEntryRequest.request.method).toBe('GET');
4949
});
5050

5151
it('loads summary with get /summary?time_offset=<time-offset>', () => {
5252
service.summary().subscribe();
5353
const timeOffset = new Date().getTimezoneOffset();
54-
const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/summary?time_offset=${timeOffset}`);
54+
const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/summary/?time_offset=${timeOffset}`);
5555
expect(loadEntryRequest.request.method).toBe('GET');
5656
});
5757

@@ -62,7 +62,7 @@ describe('EntryService', () => {
6262
const timezoneOffset = new Date().getTimezoneOffset();
6363
service.loadEntries({ year, month }).subscribe();
6464

65-
const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}?month=${month}&year=${year}&timezone_offset=${timezoneOffset}`);
65+
const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/?month=${month}&year=${year}&timezone_offset=${timezoneOffset}`);
6666
expect(loadEntryRequest.request.method).toBe('GET');
6767

6868
});
@@ -89,15 +89,15 @@ describe('EntryService', () => {
8989
service.urlInProductionLegacy = true;
9090
service.stopEntryRunning('id').subscribe();
9191

92-
const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/id/stop`);
92+
const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/id/stop/`);
9393
expect(updateEntryRequest.request.method).toBe('POST');
9494
});
9595

9696
it('stops an entry using PUT', () => {
9797
service.urlInProductionLegacy = false;
9898
service.stopEntryRunning('id').subscribe();
9999

100-
const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop`);
100+
const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop/`);
101101
expect(updateEntryRequest.request.method).toBe('PUT');
102102
});
103103

@@ -153,7 +153,7 @@ describe('EntryService', () => {
153153

154154
service.findEntriesByProjectId(projectId).subscribe();
155155

156-
const restartEntryRequest = httpMock.expectOne( `${service.baseUrl}?limit=2&project_id=${projectId}&start_date=${startDate}&end_date=${endDate}`);
156+
const restartEntryRequest = httpMock.expectOne( `${service.baseUrl}/?limit=2&project_id=${projectId}&start_date=${startDate}&end_date=${endDate}`);
157157
expect(restartEntryRequest.request.method).toBe('GET');
158158
});
159159

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,15 +501,6 @@ describe('TimeEntriesComponent', () => {
501501
expect(component.doSave).toHaveBeenCalledTimes(0);
502502
});
503503

504-
it('call cookieService.get() when call ngOnInit', () => {
505-
spyOn(cookieService, 'get');
506-
const sentParameter = FeatureToggle.TIME_TRACKER_CALENDAR;
507-
508-
component.ngOnInit();
509-
510-
expect(cookieService.get).toHaveBeenCalledWith(sentParameter);
511-
});
512-
513504

514505
it('set true in displayGridView when its initial value is false and call onDisplayModeChange', () => {
515506
const expectedValue = true;

0 commit comments

Comments
 (0)