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

Add tests for util functions #979

Merged
merged 1 commit into from
Oct 17, 2024
Merged

Add tests for util functions #979

merged 1 commit into from
Oct 17, 2024

Conversation

ajhollid
Copy link
Collaborator

This PR adds tests for util functions on the BE

  • Add tests for util functions
    • imageProcessing
    • dataUtils
    • messages
    • utils

@ajhollid ajhollid merged commit ab0f4e4 into develop Oct 17, 2024
1 of 2 checks passed
@ajhollid ajhollid deleted the feat/be/util-tests branch October 17, 2024 05:11
});

it("should throw an error if authorization header has more than two parts", () => {
const headers = { authorization: "Bearer abc def" };

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Bearer abc def" is used as
authorization header
.
Copy link

coderabbitai bot commented Oct 17, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces several changes, including updates to the server's code coverage configuration, modifications to utility functions, and the addition of multiple test files. The configuration file now includes a new directory for code coverage analysis, while the utility functions have undergone formatting changes and an export update. Additionally, new test suites have been created for various utility functions, enhancing overall test coverage and ensuring functionality across different scenarios.

Changes

File Path Change Summary
Server/.nycrc Updated "include" array to add "utils/*.js" alongside existing "controllers/*.js".
Server/utils/dataUtils.js Changed indentation style from spaces to tabs; exported calculatePercentile function.
Server/tests/utils/dataUtils.test.js Introduced unit tests for NormalizeData and calculatePercentile functions.
Server/tests/utils/imageProcessing.test.js Added tests for GenerateAvatarImage function, including image resizing and error handling.
Server/tests/utils/messages.test.js Created a test suite for message utility functions, covering both error and success messages.
Server/tests/utils/utils.test.js Introduced tests for ParseBoolean and getTokenFromHeaders functions, enhancing utility coverage.

Possibly related PRs

  • Feat/be/controller-utils-tests, #924 #930: This PR adds tests for the handleValidationError and handleError functions, which are relevant to the changes in the main PR that updated the configuration for code coverage, including the utils/*.js directory where these functions are located.
  • Feat/server auth controller tests #922: This PR introduces tests for the authController, which may indirectly relate to the changes in the main PR by ensuring that the overall testing framework is robust, including the newly added coverage for utility functions.
  • Feat/be/check controller tests, #924 #929: This PR enhances testing for the checkController, which may also relate to the overall testing strategy and coverage improvements initiated in the main PR.
  • Feat/be/invite-controller-tests, #924 #932: This PR adds tests for the inviteController, which could be relevant as it contributes to the overall testing framework that the main PR aims to enhance by including utility functions in the coverage.
  • Feat/be/maintenance-window-controller-tests, #924 #935: This PR implements tests for the maintenanceWindowController, which aligns with the main PR's goal of improving test coverage, including utilities that may be used across various controllers.

Suggested reviewers

  • marcelluscaio
  • jennifer-gan

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

const percentile = 100;
const result = calculatePercentile(checks, percentile);
const expected = 50;
console.log(result);
Copy link
Contributor

Choose a reason for hiding this comment

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

One console slipped here

Copy link
Collaborator Author

@ajhollid ajhollid Oct 17, 2024

Choose a reason for hiding this comment

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

Wooops! Good catch, will open a pr to fix asap

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