Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 579 fix unit testing #593

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

danfercf1
Copy link
Contributor

@danfercf1 danfercf1 commented Sep 25, 2024

  • The bot tests were modified to use Mocked connection for MongoDB and mocked connection for the Telegram API test. (I think the dependency "telegram-test-api" could be removed, this dependency could be keept if there is the chance to add integration tests).
  • The Lightning test was modified with small changes.
  • Added a bunch of test for bot validations.
  • The files are using the .spec in the names in order to have better organization in the folders and files structure.
  • Added some observations into the validation.js file and fixed some bugs that were found by the tests.
  • The method isOrderCreator was moved to utils in order to have a better test structure.

Fixes #579


it('should create a /sell', async () => {
const client = server.getClient(token, { timeout: 5000 });
const command = client.makeCommand('/sell 100 1 ves Pagomovil');
Copy link
Member

Choose a reason for hiding this comment

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

I have a doubt about this test, if I change the commando to a wrong command, let's say client.makeCommand('/sello 100 1 ves Pagomovil'); the test still passes, what are we testing here? can we make the test fails if the command is wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add the fail tests, the reason is that the telegram api is mocked with a certain response, for the fails tests it's necessary to add the mocks for the failed tests

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 unit tests have a controlled environment, we need to add all the mocked data to makes the test run every possible scenario

Copy link
Member

Choose a reason for hiding this comment

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

is it possible to add some mocked data on this PR? not necessary all data but something to start

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'm working on that

@@ -345,15 +340,13 @@ const validateInvoice = async (ctx: MainContext, lnInvoice: string) => {
const latestDate = new Date(
Date.now() + Number(process.env.INVOICE_EXPIRATION_WINDOW)
);
if (!("MAIN_PAYMENT_AMT" in process.env)) throw Error("MIN_PAYMENT_AMT not found, please check .env file");
if (!("MIN_PAYMENT_AMT" in process.env)) throw Error("MIN_PAYMENT_AMT not found, please check .env file");
Copy link
Contributor

Choose a reason for hiding this comment

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

@danfercf1 this looks like an unrelated change that should go in a separate PR?

Copy link
Contributor Author

@danfercf1 danfercf1 Oct 3, 2024

Choose a reason for hiding this comment

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

Yes, you are right the problem is that the test related to this implementation will not work. I've reported that problem in this issue #594

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.

Fix unit testing
3 participants