Skip to content

[CCFPCM-419] pos reconciliation service and pos deposit service unit tests#101

Merged
chelsea-EYDS merged 2 commits intomainfrom
CCFPCM-419
May 12, 2023
Merged

[CCFPCM-419] pos reconciliation service and pos deposit service unit tests#101
chelsea-EYDS merged 2 commits intomainfrom
CCFPCM-419

Conversation

@chelsea-EYDS
Copy link
Contributor

CCFPCM-0419

Objective:

  • POS reconciliation service unit tests
  • POS deposit unit tests

@chelsea-EYDS chelsea-EYDS changed the title [CCFPCM-419] POS Recon Unit Tests [CCFPCM-419] pos reconciliation service and pos deposit service unit tests May 4, 2023
@chelsea-EYDS chelsea-EYDS force-pushed the CCFPCM-419 branch 2 times, most recently from e970d6c to 2cb4b72 Compare May 5, 2023 00:49
@chelsea-EYDS chelsea-EYDS marked this pull request as draft May 5, 2023 16:34
@chelsea-EYDS chelsea-EYDS marked this pull request as ready for review May 5, 2023 17:52
Base automatically changed from CCFPCM-395 to CHORE-exceptions-service-refactor May 10, 2023 03:05
Base automatically changed from CHORE-exceptions-service-refactor to main May 10, 2023 23:20
@chelsea-EYDS chelsea-EYDS requested review from fw-noel and fwkendall May 10, 2023 23:24
@chelsea-EYDS chelsea-EYDS force-pushed the CCFPCM-419 branch 4 times, most recently from a1b0e2c to c1f3906 Compare May 11, 2023 00:02
payments[0].transaction.transaction_time = format(
getTime(
parse(
payments[0].transaction.transaction_date +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use template literals `${}` here?

Also, an explanation for the 20 minutes thing? Is it just for the one test?

parse(payments[0].transaction.transaction_time, 'HH:mm:ss', new Date()),
parse(deposits[0].transaction_time, 'HH:mm:ss', new Date())
)
).toBeGreaterThanOrEqual(20);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly are we testing here? Just that the 20 minute addition worked? It feels like we're just testing date-fns differenceInMinutes

it('should match payments to deposits according to first round of heuristics', () => {
const spy = jest.spyOn(service, 'matchPosPaymentToPosDeposits');
const roundOneTimeDiff = 5;
const timeDiff = roundOneTimeDiff;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point of roundOneTimeDiff?

timeDiff
);
matches = [...matchedRoundOne];
expect(spy).toBeCalled();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a scenario that this test fails?

timeDiff
);
matches.push(...matchedRoundTwo);
expect(spy).toBeCalled();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still wondering if there's a scenario in which this fails. And if so, how this is different from the other matchedRoundOne test, since it's the same function. I might need to read more on how the heuristics are working

@chelsea-EYDS chelsea-EYDS requested a review from fw-noel May 11, 2023 23:11
expect(itm.deposit.status === MatchStatus.MATCH);
expect(itm.payment.status === MatchStatus.MATCH);
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know exactly how many matches we have, and how many non-matches we have? Is there an argument for adding that as a test too?

import { locations } from '../../mocks/const/locations';
import { MockData } from '../../mocks/mocks';

export const setSomePaymentsToTwentyMinutesLater = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also "resetting" the payments right (as in setting the status to pending)?

I'd suggest just passing an array into this function and calling it something like resetPaymentsDataset or something, and doing the 20 minute thing for each even index within the function rather than passing in an index. With some comments to explain why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The payments are reset between tests using:
(this is a recent change :) )

  afterEach(() => {
    jest.clearAllMocks();
  });

Function has been updated to receive an array, and status updates are removed (it was redundant since the mock data generates the status as PENDING and each test will generate new data)

:)

@chelsea-EYDS chelsea-EYDS requested a review from fw-noel May 12, 2023 00:30
@@ -0,0 +1,21 @@
#!/bin/bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be in a separate pr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops wasn't planning to commit this one

}
: {
...itm,
timestamp: itm.timestamp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't itm.timestamp covered within ...itm?

@chelsea-EYDS chelsea-EYDS merged commit 6d51c88 into main May 12, 2023
@chelsea-EYDS chelsea-EYDS deleted the CCFPCM-419 branch May 12, 2023 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants