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: Test for utils.js #4150

Merged
merged 2 commits into from
Dec 19, 2024
Merged

Add: Test for utils.js #4150

merged 2 commits into from
Dec 19, 2024

Conversation

ravjot07
Copy link
Contributor

This Pr Covers test for utils.js...

test

Functions Covered by the Test(This PR):
toTitleCase: Tests converting the first character of a string to uppercase and handling non-string input.
fileExt: Tests extracting the file extension from various filenames, including those without extensions or null input.
fileBasename: Tests retrieving the basename of a file path (without the extension) and handling filenames without extensions.
last: Tests returning the last element of an array or null for empty arrays.
safeSVG: Tests escaping certain HTML entities in strings and returns non-string inputs as-is.
toFixed2: Tests formatting numbers to two decimal places when needed, and returning non-number inputs unchanged.
mixedNumber: Tests converting floating-point numbers to mixed fractions and handling integer values.
nearestBeat: Tests finding the closest beat (fraction) for a given number.
oneHundredToFraction: Tests mapping numbers (1-100) to predefined fractions.
rationalToFraction: Tests converting floating-point numbers into approximate fractional representations, including special cases like 0, NaN, and Infinity.
rgbToHex: Tests converting RGB color values to their hexadecimal string representation.
hexToRGB: Tests converting a hexadecimal color code into an RGB object, including invalid hex input handling.
hex2rgb: Tests converting a hex string into an RGBA string format.

Signed-off-by: Ravjot Singh <[email protected]>
Signed-off-by: Ravjot Singh <[email protected]>
@ravjot07
Copy link
Contributor Author

#4124

@walterbender walterbender merged commit a3f815d into sugarlabs:master Dec 19, 2024
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