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

Fix #4334: Improved Test Cases Readability and Maintainability #6

Merged
merged 3 commits into from
Oct 22, 2023

Conversation

balajis-qb
Copy link
Collaborator

Closes: Hacker0x01#4334

Summary

I have made changes to improve the maintainability of certain test cases mentioned in the issue and removed magic numbers and refactored it a bit. This enhancement aims to make the core more readable and maintainable.

Motivation and Benefits

Improving test cases maintainability and removing magic numbers helps in the following ways:

  • Enhances code readability
  • Eases future maintenance and debugging
  • Promotes best coding practices

Files Updated

  • test/filter_times_test.test.js
  • test/filter_times_test.test.js
  • test/exclude_times_test.test.js

Changes Made

  1. Replaced the magic values with meaningful constants for clarity.
  2. Replaced few other magic values with the actual computation logic for clarity.
  3. Splitted test cases for separate one test case from other.

Balaji Sridharan added 3 commits October 21, 2023 16:31
In this commit, I've mad the following enhancements to the code:
1. Split the test-cases and move the test-case for checking the aria-disabled attribute to a separate it block.
2. Changed the use of the magic number 4 to the length of the input array excludeTimes for better flexibility and maintainability.

Closes Hacker0x01#4334
In this commit, I've made the following enhancements to the code:
1. Replaced the magic value 17 with meaning constant for clarity.
2. Instead of directly checking the disabledTimeItems.length to be 2, make sure whether it's really the value we assigned (17 or 5pm).
3. Split the test-cases and move the test-case for checking the aria-disabled attribute to a separate it block.

Closes Hacker0x01#4334
In this commit, I've made the following enhancements to the code:
1. Change the test case of finding the disabled time units count to the finding the enabled time units as the module involves on the existence of the includeTimes
2. Moved the test case to find the enabled time units through aria-disabled attribute to the separate it block
3. Replaced the magic value 45 with the actual computation which resolves to the magic value, to make it more maintainable and readable

Closes Hacker0x01#4334
@balajis-qb balajis-qb merged commit 33f655e into main Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant