Skip to content

Commit

Permalink
test(tests): ✅ Add test cases for get-last-from function
Browse files Browse the repository at this point in the history
Add test cases to validate the functionality of the `get-last-from` function, covering various input scenarios. This ensures robust testing and verification of the `get-last-from` function's behavior. The addition of these test cases enhances the reliability of the `get-last-from` function.

Fix #258
  • Loading branch information
krypton225 committed Dec 31, 2023
1 parent 45d067b commit ded8316
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/functions/list/_get-last-element.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@charset "UTF-8";

// @description
// * get-last-from function.
// * This module tests a functionality of get-last-from function.

// @access private

// @version 1.0.0

// @author Khaled Mohamed

// @license MIT

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

// @namespace list

// @module list/get-last-element.test

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

// stylelint-disable function-name-case

@use "sass:map";
@use "../../../node_modules/sass-true/sass/true" as True;
@use "../../../src/functions/list/get-last-element" as LibFunc;
@use "../../../src/development-utils/error" as Dev;

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

@each $case, $result in $test-cases-get-last-from-map {
@include True.describe("[Function] get-last-from(#{$case}), Result: #{$result}") {
@include True.it("get-last-from( #{$case}).") {
@include True.assert-equal(LibFunc.get-last-from($case), $result);
}
}
}
6 changes: 6 additions & 0 deletions tests/functions/list/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@
// * please see testing `get-first-from` function for details.
// @see get-first-from
@forward "get-first-element.test";

// * get-last-element-list forward.
// * forwarding the testing get-last-from function.
// * please see testing `get-last-from` function for details.
// @see get-last-from
@forward "get-last-element.test";

0 comments on commit ded8316

Please sign in to comment.