Skip to content

Commit

Permalink
chore: check currentEvent occurredAt property
Browse files Browse the repository at this point in the history
  • Loading branch information
simonadomnisoru committed Dec 1, 2023
1 parent 9f0f252 commit 452383c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export const getStructureEvents = (compareDates: CompareDates) => {
event.eventId !== currentEvent.eventId,
);

const events = [...otherEventsFiltered, ...(Object.keys(currentEvent).length !== 0 ? [currentEvent] : [])]
.sort(compareEvents);
const events = currentEvent.occurredAt ? otherEventsFiltered.concat(currentEvent) : otherEventsFiltered;
const sortedEvents = events.sort(compareEvents);

return createEventsContainer(events);
return createEventsContainer(sortedEvents);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Event Event rules engine', () => {

describe.each([
[
{ vANAXwtLwcT: 0 },
{ vANAXwtLwcT: 0, occurredAt: '2020-04-30T22:00:00.000Z' },
[
{
id: 'vANAXwtLwcT',
Expand All @@ -92,15 +92,15 @@ describe('Event Event rules engine', () => {
],
],
[
{ vANAXwtLwcT: 9 },
{ vANAXwtLwcT: 9, occurredAt: '2020-04-30T22:00:00.000Z' },
[{ id: 'Ok9OQpitjQr', targetDataType: rulesEngineEffectTargetDataTypes.DATA_ELEMENT, type: 'HIDEFIELD' }],
],
[
{ vANAXwtLwcT: 99 },
{ vANAXwtLwcT: 99, occurredAt: '2020-04-30T22:00:00.000Z' },
[{ id: 'Ok9OQpitjQr', targetDataType: rulesEngineEffectTargetDataTypes.DATA_ELEMENT, type: 'HIDEFIELD' }],
],
[
{ vANAXwtLwcT: 100 },
{ vANAXwtLwcT: 100, occurredAt: '2020-04-30T22:00:00.000Z' },
[
{
id: 'vANAXwtLwcT',
Expand All @@ -127,7 +127,7 @@ describe('Event Event rules engine', () => {

describe.each([
[
{ sWoqcoByYmD: true },
{ sWoqcoByYmD: true, occurredAt: '2020-04-30T22:00:00.000Z' },
[
{
id: 'vANAXwtLwcT',
Expand All @@ -138,7 +138,7 @@ describe('Event Event rules engine', () => {
],
],
[
{ sWoqcoByYmD: false },
{ sWoqcoByYmD: false, occurredAt: '2020-04-30T22:00:00.000Z' },
[
{
id: 'vANAXwtLwcT',
Expand Down Expand Up @@ -269,7 +269,7 @@ describe('Event rules engine', () => {

describe.each([
[
{ oZg33kd9taw: 'Female', SWfdB5lX0fk: null },
{ oZg33kd9taw: 'Female', SWfdB5lX0fk: null, occurredAt: '2020-04-30T22:00:00.000Z' },
[
{
displayKeyValuePair: { id: 'x7PaHGvgWY2', key: 'BMI', value: '' },
Expand All @@ -279,7 +279,7 @@ describe('Event rules engine', () => {
],
],
[
{ oZg33kd9taw: 'Male', SWfdB5lX0fk: null },
{ oZg33kd9taw: 'Male', SWfdB5lX0fk: null, occurredAt: '2020-04-30T22:00:00.000Z' },
[
{ id: 'SWfdB5lX0fk', targetDataType: rulesEngineEffectTargetDataTypes.DATA_ELEMENT, type: 'HIDEFIELD' },
{
Expand All @@ -290,7 +290,7 @@ describe('Event rules engine', () => {
],
],
[
{ oZg33kd9taw: null, SWfdB5lX0fk: null },
{ oZg33kd9taw: null, SWfdB5lX0fk: null, occurredAt: '2020-04-30T22:00:00.000Z' },
[
{
displayKeyValuePair: { id: 'x7PaHGvgWY2', key: 'BMI', value: '' },
Expand Down

0 comments on commit 452383c

Please sign in to comment.