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 #4335

Conversation

balajis-qb
Copy link

Closes: #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
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network.


@balajis-qb you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest Breakdown

Reviewable lines of change

+ 94
- 27

100% JavaScript (tests)

Type of change

Fix - These changes are likely to be fixing a bug or issue.

@codecov
Copy link

codecov bot commented Oct 21, 2023

Codecov Report

Merging #4335 (b392082) into main (7ad0d20) will not change coverage.
The diff coverage is n/a.

❗ Current head b392082 differs from pull request most recent head 7ada98d. Consider uploading reports for the commit 7ada98d to get more accurate results

@@           Coverage Diff           @@
##             main    #4335   +/-   ##
=======================================
  Coverage   96.63%   96.63%           
=======================================
  Files          27       27           
  Lines        2375     2375           
  Branches      953      953           
=======================================
  Hits         2295     2295           
  Misses         80       80           

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

These test clean-ups look good—I don't see any issues here.

Image of Eric E Eric E


Reviewed with ❤️ by PullRequest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants