mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 22:34:56 +00:00
- Added a new Slider component with support for controlled and uncontrolled values, marks, value labels, and customizable styles. - Introduced new props for Slider including min, max, step, orientation, color, size, and disabled state. - Implemented internal state management for value and visibility of value labels. - Created SCSS styles for the Slider component, supporting various orientations, sizes, and color variants. - Added accessibility features to the Slider component, including ARIA attributes. chore: Introduce assertion utilities and refactor assertion functions - Created standalone assertion functions (assertTrue, assertFalse, assertEqual, etc.) for better test readability. - Developed assertion utilities for error handling and value stringification. - Refactored existing assertion functions to utilize the new utility functions for improved maintainability. - Implemented a chainable expect() function with various matchers for enhanced testing capabilities.
72 lines
2.1 KiB
Lua
72 lines
2.1 KiB
Lua
-- Standalone assertion functions
|
|
-- Provides assertTrue, assertFalse, assertEqual, etc.
|
|
|
|
local utils = require("assert_utils")
|
|
|
|
---@class AssertModule
|
|
local M = {}
|
|
|
|
---Assert that a value is truthy
|
|
---@param value any Value to check
|
|
---@param message? string Optional custom error message
|
|
function M.assertTrue(value, message)
|
|
if not value then
|
|
error(utils.assertionError(message or "Expected true", true, value))
|
|
end
|
|
end
|
|
|
|
---Assert that a value is falsy
|
|
---@param value any Value to check
|
|
---@param message? string Optional custom error message
|
|
function M.assertFalse(value, message)
|
|
if value then
|
|
error(utils.assertionError(message or "Expected false", false, value))
|
|
end
|
|
end
|
|
|
|
---Assert that two values are equal (strict)
|
|
---@param actual any Actual value
|
|
---@param expected any Expected value
|
|
---@param message? string Optional custom error message
|
|
function M.assertEqual(actual, expected, message)
|
|
if actual ~= expected then
|
|
error(utils.assertionError(message or "Values not equal", expected, actual))
|
|
end
|
|
end
|
|
|
|
---Assert that two values are not equal
|
|
---@param actual any Actual value
|
|
---@param expected any Value that actual should not equal
|
|
---@param message? string Optional custom error message
|
|
function M.assertNotEqual(actual, expected, message)
|
|
if actual == expected then
|
|
error(utils.assertionError(message or "Values should not be equal", "not " .. utils.stringify(expected), actual))
|
|
end
|
|
end
|
|
|
|
---Assert that a value is nil
|
|
---@param value any Value to check
|
|
---@param message? string Optional custom error message
|
|
function M.assertNil(value, message)
|
|
if value ~= nil then
|
|
error(utils.assertionError(message or "Expected nil", nil, value))
|
|
end
|
|
end
|
|
|
|
---Assert that a value is not nil
|
|
---@param value any Value to check
|
|
---@param message? string Optional custom error message
|
|
function M.assertNotNil(value, message)
|
|
if value == nil then
|
|
error(utils.assertionError(message or "Expected not nil", "not nil", nil))
|
|
end
|
|
end
|
|
|
|
---Explicitly fail a test
|
|
---@param message? string Optional failure message
|
|
function M.fail(message)
|
|
error(utils.assertionError(message or "Test failed", nil, nil))
|
|
end
|
|
|
|
return M
|