Skip to content

Commit

Permalink
test(tests): ✅ Forward list utilities & add testing for flatten fun…
Browse files Browse the repository at this point in the history
…ction

Add forwarding for `list` module in functions index. Introduce a new test module for the flatten function with comprehensive test cases. The testing aims to ensure the accuracy and robustness of the flatten function for various input scenarios.

Fix #255
  • Loading branch information
krypton225 committed Dec 28, 2023
1 parent acdf549 commit 375ab18
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/functions/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
// * This module likely contains global utilities or functions.
// @see global
@forward "global";

// * forwarding the "list" module.
// * This module likely contains list utilities or functions.
// @see list
@forward "list";
49 changes: 49 additions & 0 deletions tests/functions/list/_flatten-list.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@charset "UTF-8";

// @description
// * flatten function.
// * This module tests a functionality of flatten function.

// @access private

// @version 1.0.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/krypton225/sass-pire

// @namespace global

// @module global/flatten.test

// @dependencies:
// * - true.describe (true function).
// * - true.it (true function).
// * - true.assert-equal (true function).
// * - err (function).

@use "sass:map";
@use "../../../node_modules/sass-true/sass/true" as True;
@use "../../../src/functions/list/flatten-list" as func;
@use "../../../src/development-utils/error" as dev;

$test-cases-flatten-list-map: (
(1, 2, 4): (1 2 4),
344px: dev.err("The parameter of flatten function must be in a list type."),
(69, 48, 54, (32, (11, 43))): (69 48 54 32 11 43),
((true, false), (0, "Just a text"), (2, 32, 4)): (true false 0 "Just a text" 2 32 4),
(69, 48, 54, (32, (11, 43, (21, (11, "Yes"))))): (69 48 54 32 11 43 21 11 "Yes"),
true: dev.err("The parameter of flatten function must be in a list type."),
"Just a number": dev.err("The parameter of flatten function must be in a list type."),
false: dev.err("The parameter of flatten function must be in a list type."),
);

@each $case, $result in $test-cases-flatten-list-map {
@include True.describe("[Function] flatten(#{$case}), Result: #{$result}") {
@include True.it("Cut the unit of (#{$case}) value.") {
@include True.assert-equal(func.flatten($case), $result);
}
}
}
19 changes: 19 additions & 0 deletions tests/functions/list/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@charset "UTF-8";

// @description
// * This file forwards key functionalities from other modules.
// * for easy access in the current stylesheet.

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/krypton225/sass-pire

// @namespace functions/list

// * flatten-list forward.
// * forwarding the testing flatten function.
// * please see testing `flatten` function for details.
// @see flatten-list
@forward "flatten-list.test";

0 comments on commit 375ab18

Please sign in to comment.