camicroscope / caMicroscope

Digital pathology image viewer with support for human/machine generated annotations and markups.
BSD 3-Clause "New" or "Revised" License
247 stars 286 forks source link

Unit Test : Add User Function Test #864

Open barchakuz opened 5 months ago

barchakuz commented 5 months ago

Unit Test 1 : Add User function

Summary

This pull request adds test code using the Jest framework for the addUser function in the Signup.js file. The tests cover various scenarios including email validation, different user types, API calls, and error handling.

Motivation

The motivation behind this pull request is to ensure the correctness and reliability of the addUser function by implementing comprehensive test coverage. This helps in catching bugs early and ensuring that the function behaves as expected under different conditions.

Testing

The test code has been written using Jest and includes mocks for external dependencies like document.getElementById and fetch to simulate user input and API requests. Each test case covers a specific scenario, and the test suite has been run using the Jest CLI to verify the functionality.

birm commented 5 months ago

Hi! This looks interesting! How did you run/set this for testing?

barchakuz commented 5 months ago

@birm I've integrated Jest, a JavaScript testing framework, for unit testing. I've utilized a custom script in test.signup to automate form submission. The values for the form are visible within the test script.