Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ describe('Reports Page', () => {
});
});

it('The data should be displayed as a multiple of hour when column is equal to 3', () => {
const column = 3;
it('The data should be displayed as a multiple of hour when column is equal to 4', () => {
const column = 4;
expect(component.bodyExportOptions(durationTime, row, column, node)).toMatch(decimalValidator);
});

it('The data should not be displayed as a multiple of hour when column is different of 3', () => {
const column = 4;
it('The data should not be displayed as a multiple of hour when column is different of 4', () => {
const column = 5;
expect(component.bodyExportOptions(durationTime, row, column, node)).toBe(durationTime.toString());
});

Expand Down Expand Up @@ -217,6 +217,54 @@ describe('Reports Page', () => {
expect({hours, minutes, seconds}).toEqual({hours:0, minutes:0, seconds:0});
});

it('should export data with the correct format', () => {
const data = [
'<mat-checkbox _ngcontent-tst-c180="" class="mat-checkbox mat-accent" id="mat-checkbox-27"><label class="mat-checkbox-layout" for="mat-checkbox-27-input"><span class="mat-checkbox-inner-container mat-checkbox-inner-container-no-side-margin"><input type="checkbox" class="mat-checkbox-input cdk-visually-hidden" id="mat-checkbox-27-input" tabindex="0" aria-checked="false"><span matripple="" class="mat-ripple mat-checkbox-ripple mat-focus-indicator" ng-reflect-trigger="[object HTMLLabelElement]" ng-reflect-disabled="false" ng-reflect-radius="20" ng-reflect-centered="true" ng-reflect-animation="[object Object]"><span class="mat-ripple-element mat-checkbox-persistent-ripple"></span></span><span class="mat-checkbox-frame"></span><span class="mat-checkbox-background"><svg version="1.1" focusable="false" viewBox="0 0 24 24" xml:space="preserve" class="mat-checkbox-checkmark"><path fill="none" stroke="white" d="M4.1,12.7 9,17.6 20.3,6.3" class="mat-checkbox-checkmark-path"></path></svg><span class="mat-checkbox-mixedmark"></span></span></span><span class="mat-checkbox-label"><span style="display: none;">&nbsp;</span></span></label></mat-checkbox>',
'19',
'[email protected]',
'07/01/2022',
'09:00',
'09:00',
'18:00',
'Project_Name',
'3',
'Customer_Name',
'3',
'Activity_Name',
`<a _ngcontent-tst-c180="" class="is-url ng-star-inserted"> https://ioetec.atlassian.net/browse/CB-115 </a><!--ng-container--><!--bindings={
"ng-reflect-ng-if": "true"
}-->`,
'',
`<div _ngcontent-tst-c180="" class="badge bg-secondary text-wrap ng-star-inserted"> git </div><!--bindings={
"ng-reflect-ng-for-of": "git"
}--><!--ng-container--><!--bindings={
"ng-reflect-ng-if": "true"
}-->`
];
const dataFormat = [
'<span matripple="" class="mat-ripple mat-checkbox-ripple mat-focus-indicator" ng-reflect-trigger="[object HTMLLabelElement]" ng-reflect-disabled="false" ng-reflect-radius="20" ng-reflect-centered="true" ng-reflect-animation="[object Object]">&nbsp;',
'19',
'[email protected]',
'07/01/2022',
'9.00',
'09:00',
'18:00',
'Project_Name',
'3',
'Customer_Name',
'3',
'Activity_Name',
' https://ioetec.atlassian.net/browse/CB-115 ',
'',
' git '
];

data.forEach((value: any, index) => {
const formatValue = component.bodyExportOptions(value, row, index, node);
expect(formatValue).toEqual(dataFormat[index]);
});
});

afterEach(() => {
fixture.destroy();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn

bodyExportOptions(data, row, column, node) {
const dataFormated = data.toString().replace(/<((.|\n){0,200}?)>/gi, '');
const durationColumnIndex = 3;
const durationColumnIndex = 4;
return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated;
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/time-clock/services/entry.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import * as moment from 'moment';
describe('EntryService', () => {
let service: EntryService;
let httpMock: HttpTestingController;
var reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report';
let reportsUrl: any;

beforeEach(() => {
TestBed.configureTestingModule({imports: [HttpClientTestingModule], providers: [DatePipe]});
service = TestBed.inject(EntryService);
httpMock = TestBed.inject(HttpTestingController);
service.baseUrl = 'time-entries';
reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report';
});

it('services are ready to be used', inject(
Expand Down