Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: TT-336 Changes in time entries unit tests
  • Loading branch information
Edgar Guaman committed Sep 17, 2021
commit 9b129b87f438e870b7b938ec1acd937342517dc8
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterLinkWithHref } from '@angular/router';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { Entry } from 'src/app/modules/shared/models';
import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe';
Expand All @@ -13,6 +14,9 @@ describe('Reports Page', () => {
let store: MockStore<EntryState>;
let getReportDataSourceSelectorMock;
let durationTime: number;
let row: number;
let node: number;
let decimalValidator: RegExp;
const timeEntry: Entry = {
id: '123',
start_date: new Date(),
Expand Down Expand Up @@ -65,6 +69,9 @@ describe('Reports Page', () => {

beforeEach(() => {
durationTime = new Date().setHours(5, 30);
row = 0;
node = 0;
decimalValidator = /^\d+\.\d{0,2}$/;
});

it('component should be created', async () => {
Expand Down Expand Up @@ -113,11 +120,14 @@ describe('Reports Page', () => {
});

it('The data should be displayed as a multiple of hour when column is equal to 3', () => {
expect(component.bodyExportOptions(durationTime, 0, 3, 0)).toMatch(/^\d+\.\d{0,2}$/);
const column = 3;

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', () => {
expect(component.bodyExportOptions(durationTime, 0, 4, 0)).toBe(durationTime);
const column = 4;
expect(component.bodyExportOptions(durationTime, row, column, node)).toBe(durationTime);
});

afterEach(() => {
Expand Down