From f0f84513f8efe533b6ee670a6f1a0c074387b2ec Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 13 Aug 2025 12:01:46 +0200 Subject: Make use of SASS modules --- test/_functions.scss | 104 +++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'test/_functions.scss') diff --git a/test/_functions.scss b/test/_functions.scss index 07561ef..4d545db 100644 --- a/test/_functions.scss +++ b/test/_functions.scss @@ -2,56 +2,56 @@ @use '../src/functions'; @include describe('functions') { - @include it('str-replace') { - $str: 'Hello world!'; - - @include assert-equal(functions.str-replace($str, 'world', 'neighbor'), 'Hello neighbor!', 'Replace "world" with "neighbor"'); - @include assert-equal(functions.str-replace($str, 'neighbor', 'moon'), 'Hello world!', 'Replace "neighbor" with "moon"'); - @include assert-equal(functions.str-replace($str, 'Hello', 'Bye'), 'Bye world!', 'Replace "Hello" with "Bye"'); - } - - @include it('list-slice') { - $list: 'this' 'is' 'a' 'list'; - - @include assert-equal(functions.list-slice($list, 2), 'is' 'a' 'list', 'Discard first item'); - @include assert-equal(functions.list-slice($list, 1, 3), 'this' 'is' 'a', 'Keep first 3 items'); - @include assert-equal(functions.list-slice($list, 2, 3), 'is' 'a', 'Extract list from index 2 to 3'); - @include assert-equal(functions.list-slice($list, -1, -1), join((), 'list'), 'Keep last item'); - @include assert-equal(functions.list-slice($list, -1, 1), 'list' 'this', 'Extract first and last item'); - } - - @include it('list-prepend') { - $list: 'this' 'is' 'a' 'list'; - - @include assert-equal(functions.list-prepend($list, 'and'), 'and' 'this' 'is' 'a' 'list', 'Prepend "and"'); - @include assert-equal(functions.list-prepend($list, 2), 2 'this' 'is' 'a' 'list', 'Prepend 2'); - } - - @include it('quicksort') { - @include assert-equal(functions.quicksort(1 2 3 4 5), 1 2 3 4 5, 'Already sorted list of 5 items'); - @include assert-equal(functions.quicksort(1 3 2), 1 2 3, 'Random list of 3 items'); - @include assert-equal(functions.quicksort(6 3 7 3 8 1 4), 1 3 3 4 6 7 8, 'Random list of 7 items, one duplicate'); - @include assert-equal(functions.quicksort(1 1 1 1), 1 1 1 1, 'List of 4 identical items'); - } - - @include it('map-get-default') { - $map: ('key': 'value', 'another': 'item'); - - @include assert-equal(functions.map-get-default($map, 'another', 0), map-get($map, 'another'), 'Get existing value'); - @include assert-equal(functions.map-get-default($map, 'index', 'nothing'), 'nothing', 'Get missing value'); - } - - @include it('strip-unit') { - @include assert-true(unitless(functions.strip-unit(1em)), 'Remove unit from 1em'); - @include assert-true(unitless(functions.strip-unit(2rem)), 'Remove unit from 2rem'); - @include assert-true(unitless(functions.strip-unit(3px)), 'Remove unit from 3px'); - @include assert-true(unitless(functions.strip-unit(4)), 'Remove unit from 4'); - @include assert-true(unitless(functions.strip-unit(5pt)), 'Remove unit from 5pt'); - } - - @include it('px-to-rem') { - @include assert-equal(functions.px-to-rem(16px, 16px), 1rem, 'Convert 16px'); - @include assert-equal(functions.px-to-rem(32px, 16px), 2rem, 'Convert 16px'); - @include assert-equal(functions.px-to-rem(8px, 16px), 0.5rem, 'Convert 16px'); - } + @include it('str-replace') { + $str: 'Hello world!'; + + @include assert-equal(functions.str-replace($str, 'world', 'neighbor'), 'Hello neighbor!', 'Replace "world" with "neighbor"'); + @include assert-equal(functions.str-replace($str, 'neighbor', 'moon'), 'Hello world!', 'Replace "neighbor" with "moon"'); + @include assert-equal(functions.str-replace($str, 'Hello', 'Bye'), 'Bye world!', 'Replace "Hello" with "Bye"'); + } + + @include it('list-slice') { + $list: 'this' 'is' 'a' 'list'; + + @include assert-equal(functions.list-slice($list, 2), 'is' 'a' 'list', 'Discard first item'); + @include assert-equal(functions.list-slice($list, 1, 3), 'this' 'is' 'a', 'Keep first 3 items'); + @include assert-equal(functions.list-slice($list, 2, 3), 'is' 'a', 'Extract list from index 2 to 3'); + @include assert-equal(functions.list-slice($list, -1, -1), join((), 'list'), 'Keep last item'); + @include assert-equal(functions.list-slice($list, -1, 1), 'list' 'this', 'Extract first and last item'); + } + + @include it('list-prepend') { + $list: 'this' 'is' 'a' 'list'; + + @include assert-equal(functions.list-prepend($list, 'and'), 'and' 'this' 'is' 'a' 'list', 'Prepend "and"'); + @include assert-equal(functions.list-prepend($list, 2), 2 'this' 'is' 'a' 'list', 'Prepend 2'); + } + + @include it('quicksort') { + @include assert-equal(functions.quicksort(1 2 3 4 5), 1 2 3 4 5, 'Already sorted list of 5 items'); + @include assert-equal(functions.quicksort(1 3 2), 1 2 3, 'Random list of 3 items'); + @include assert-equal(functions.quicksort(6 3 7 3 8 1 4), 1 3 3 4 6 7 8, 'Random list of 7 items, one duplicate'); + @include assert-equal(functions.quicksort(1 1 1 1), 1 1 1 1, 'List of 4 identical items'); + } + + @include it('map-get-default') { + $map: ('key': 'value', 'another': 'item'); + + @include assert-equal(functions.map-get-default($map, 'another', 0), map-get($map, 'another'), 'Get existing value'); + @include assert-equal(functions.map-get-default($map, 'index', 'nothing'), 'nothing', 'Get missing value'); + } + + @include it('strip-unit') { + @include assert-true(unitless(functions.strip-unit(1em)), 'Remove unit from 1em'); + @include assert-true(unitless(functions.strip-unit(2rem)), 'Remove unit from 2rem'); + @include assert-true(unitless(functions.strip-unit(3px)), 'Remove unit from 3px'); + @include assert-true(unitless(functions.strip-unit(4)), 'Remove unit from 4'); + @include assert-true(unitless(functions.strip-unit(5pt)), 'Remove unit from 5pt'); + } + + @include it('px-to-rem') { + @include assert-equal(functions.px-to-rem(16px, 16px), 1rem, 'Convert 16px'); + @include assert-equal(functions.px-to-rem(32px, 16px), 2rem, 'Convert 16px'); + @include assert-equal(functions.px-to-rem(8px, 16px), .5rem, 'Convert 16px'); + } } -- cgit v1.2.3-70-g09d2