sbrin / lopaka

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

Write unit tests with jest for the rest of ./js/utils.js functions #5

Closed sbrin closed 1 year ago

sbrin commented 1 year ago

Write unit tests with jest for the rest of ./js/utils.js functions:

Skip following stages as it is already done before:

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. Create test for getElementByOffset function
    • Create a test for the getElementByOffset function in the utils.js file. This function takes an array of layer objects and x, y coordinates as arguments and returns the first layer object that contains the given coordinates. The test should create a mock array of layer objects and test the function with various x, y coordinates to ensure it returns the correct layer object.
  2. Create test for imgDataToUint32Array function
    • Create a test for the imgDataToUint32Array function in the utils.js file. This function takes an ImageData object and converts it to an array of 32-bit unsigned integers, where each bit represents a pixel in the image. The test should create a mock ImageData object and test the function to ensure it returns the correct array of 32-bit unsigned integers.
  3. Create test for getUint32Code function
    • Create a test for the getUint32Code function in the utils.js file. This function takes a context object and generates a string of code that represents an image in the form of an array of 32-bit unsigned integers. The test should create a mock context object and test the function to ensure it returns the correct string of code.
  4. Create test for getU8g2Code function
    • Create a test for the getU8g2Code function in the utils.js file. This function takes an element object, a boolean indicating whether the element has been declared, and a context object, and generates a string of code that represents the element in the U8g2 library. The test should create mock element objects and context objects and test the function to ensure it returns the correct string of code.
  5. Create test for getFlipperCode function
    • Create a test for the getFlipperCode function in the utils.js file. This function takes an element object and a boolean indicating whether the element has been declared, and generates a string of code that represents the element in the Flipper library. The test should create mock element objects and test the function to ensure it returns the correct string of code.
  6. Create test for generateCode function
    • Create a test for the generateCode function in the utils.js file. This function takes an array of screen elements, a boolean indicating whether the screen is inverted, a library name, and a context object, and generates a string of code that represents the screen elements in the specified library. The test should create mock screen elements and context objects and test the function with various library names to ensure it returns the correct string of code.
  7. Create test for getTextWidth function
    • Create a test for the getTextWidth function in the utils.js file. This function takes a text string and a font name as arguments and returns the width of the text string in the specified font. The test should test the function with various text strings and font names to ensure it returns the correct width.

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

sbrin commented 1 year ago

LGTM