sbrin / lopaka

Lopaka - Stunning graphics for embedded systems displays
https://lopaka.app
Apache License 2.0
325 stars 19 forks source link

Write unit tests with jest for ./js/utils.js #3

Closed sbrin closed 1 year ago

sbrin commented 1 year ago

Write unit tests with jest for all ./js/utils.js functions

ellipsis-dev[bot] commented 1 year ago

To have BitBuilder create a Pull Request with the implementation, the user who created the issue (@sbrin) can comment below with "LGTM".


Implementation Steps

  1. Setup Jest Testing Environment
    • First, we need to setup the Jest testing environment. This involves installing Jest and other necessary dependencies. Run npm install --save-dev jest to install Jest. Also, install babel-jest and @babel/preset-env for transpiling our code for Jest with npm install --save-dev babel-jest @babel/preset-env. Create a .babelrc file in the root directory and add { "presets": ["@babel/preset-env"] } to it. This will ensure that our ES6 code is transpiled correctly for Jest.
  2. Create Test File
    • Create a new file in the tests directory named utils.test.js. This file will contain all of our unit tests for the functions in utils.js.
  3. Write Test for bline Function
    • In the utils.test.js file, write a test for the bline function. This function takes in several parameters and manipulates an image data object. To test this function, you will need to create a mock image data object and pass it to the function along with other parameters. Then, assert that the image data object has been manipulated as expected.
  4. Write Test for drawCircle Function
    • In the utils.test.js file, write a test for the drawCircle function. This function takes in several parameters and manipulates an image data object. To test this function, you will need to create a mock image data object and pass it to the function along with other parameters. Then, assert that the image data object has been manipulated as expected.
  5. Write Test for drawDisc Function
    • In the utils.test.js file, write a test for the drawDisc function. This function takes in several parameters and manipulates an image data object. To test this function, you will need to create a mock image data object and pass it to the function along with other parameters. Then, assert that the image data object has been manipulated as expected.
  6. Write Test for maskBlack Function
    • In the utils.test.js file, write a test for the maskBlack function. This function takes in several parameters and manipulates an image data object. To test this function, you will need to create a mock image data object and pass it to the function along with other parameters. Then, assert that the image data object has been manipulated as expected.

Generated with :heart: by www.bitbuilder.ai. Questions? Check out our the documentation.

sbrin commented 1 year ago

LGTM