Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/time-tracker-ui-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- name: Running tests
run: |
chmod -R 777 ./$home
apt-get install libsecret-1-dev
make test
- name: Generate coverage report
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('ProjectService', () => {
service.getRecentProjects().subscribe((projectsInResponse) => {
expect(projectsInResponse.length).toBe(projectsFoundSize);
});
const getProjectsRequest = httpMock.expectOne(`${service.url}/recent`);
const getProjectsRequest = httpMock.expectOne(`${service.url}/recent/`);
expect(getProjectsRequest.request.method).toBe('GET');
getProjectsRequest.flush(projectsList);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ProjectActionTypes } from './project.actions';
import { ProjectEffects } from './project.effects';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ToastrModule, ToastrService } from 'ngx-toastr';
import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY } from '../../../../../shared/messages';
import { INFO_SAVED_SUCCESSFULLY, PROJECT_DEACTIVATED_SUCCESSFULLY } from '../../../../../shared/messages';

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

effects.deleteProject$.subscribe((action) => {
expect(toastrService.success).toHaveBeenCalledWith(INFO_DELETE_SUCCESSFULLY);
expect(toastrService.success).toHaveBeenCalledWith(PROJECT_DEACTIVATED_SUCCESSFULLY);
expect(action.type).toEqual(ProjectActionTypes.DELETE_PROJECT_SUCCESS);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,4 @@ describe('InjectTokenInterceptor test', () => {
expect(handler.handle).toHaveBeenCalledWith(request);
});

it('if request.url is part of time-tracker-api, then Authorization header is injected', () => {
const interceptor = new InjectTokenInterceptor(azureAdB2CService, loginService);
interceptor.isProduction = true;
const request = new HttpRequest('GET', environment.timeTrackerApiUrl);
spyOn(handler, 'handle');
const requestWithHeaders = request.clone(
{
headers: request.headers.set('Authorization', 'Bearer XYZ')
});

interceptor.intercept(request, handler);

expect(handler.handle).toHaveBeenCalledWith(requestWithHeaders);
});

});
16 changes: 8 additions & 8 deletions src/app/modules/time-clock/services/entry.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('EntryService', () => {
service = TestBed.inject(EntryService);
httpMock = TestBed.inject(HttpTestingController);
service.baseUrl = 'time-entries';
reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report';
reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report/';
});

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

const createEntryRequest = httpMock.expectOne(service.baseUrl);
const createEntryRequest = httpMock.expectOne(`${service.baseUrl}/`);
expect(createEntryRequest.request.method).toBe('POST');
createEntryRequest.flush(entry);
});

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

const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/running`);
const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/running/`);
expect(loadEntryRequest.request.method).toBe('GET');
});

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

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

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

});
Expand All @@ -89,15 +89,15 @@ describe('EntryService', () => {
service.urlInProductionLegacy = true;
service.stopEntryRunning('id').subscribe();

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

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

const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop`);
const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop/`);
expect(updateEntryRequest.request.method).toBe('PUT');
});

Expand Down Expand Up @@ -153,7 +153,7 @@ describe('EntryService', () => {

service.findEntriesByProjectId(projectId).subscribe();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,6 @@ describe('TimeEntriesComponent', () => {
expect(component.doSave).toHaveBeenCalledTimes(0);
});

it('call cookieService.get() when call ngOnInit', () => {
spyOn(cookieService, 'get');
const sentParameter = FeatureToggle.TIME_TRACKER_CALENDAR;

component.ngOnInit();

expect(cookieService.get).toHaveBeenCalledWith(sentParameter);
});


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