aboutsummaryrefslogtreecommitdiffstats
path: root/test/_functions.scss
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2022-02-05 07:52:13 +0100
committerVolpeon <git@volpeon.ink>2022-02-05 07:52:13 +0100
commitdd5f3c463fab336d694f426dcad11a1783590fc9 (patch)
treefaebf738a9556eaa393371852ed86550d4adf66a /test/_functions.scss
parentFix errors from transition from node-sass to sass (diff)
downloadiro-sass-dd5f3c463fab336d694f426dcad11a1783590fc9.tar.gz
iro-sass-dd5f3c463fab336d694f426dcad11a1783590fc9.tar.bz2
iro-sass-dd5f3c463fab336d694f426dcad11a1783590fc9.zip
Ported from import syntax to modules
Diffstat (limited to 'test/_functions.scss')
-rw-r--r--test/_functions.scss83
1 files changed, 43 insertions, 40 deletions
diff --git a/test/_functions.scss b/test/_functions.scss
index 54e37c5..2430f28 100644
--- a/test/_functions.scss
+++ b/test/_functions.scss
@@ -1,44 +1,47 @@
1@include describe('Functions') { 1@use 'true' as *;
2 @include it('iro-str-replace') { 2@use '../src/functions';
3
4@include describe('functions') {
5 @include it('str-replace') {
3 $str: 'Hello world!'; 6 $str: 'Hello world!';
4 7
5 @include assert-equal(iro-str-replace($str, 'world', 'neighbor'), 'Hello neighbor!', 'Replace "world" with "neighbor"'); 8 @include assert-equal(functions.str-replace($str, 'world', 'neighbor'), 'Hello neighbor!', 'Replace "world" with "neighbor"');
6 @include assert-equal(iro-str-replace($str, 'neighbor', 'moon'), 'Hello world!', 'Replace "neighbor" with "moon"'); 9 @include assert-equal(functions.str-replace($str, 'neighbor', 'moon'), 'Hello world!', 'Replace "neighbor" with "moon"');
7 @include assert-equal(iro-str-replace($str, 'Hello', 'Bye'), 'Bye world!', 'Replace "Hello" with "Bye"'); 10 @include assert-equal(functions.str-replace($str, 'Hello', 'Bye'), 'Bye world!', 'Replace "Hello" with "Bye"');
8 } 11 }
9 12
10 @include it('iro-list-slice') { 13 @include it('list-slice') {
11 $list: 'this' 'is' 'a' 'list'; 14 $list: 'this' 'is' 'a' 'list';
12 15
13 @include assert-equal(iro-list-slice($list, 2), 'is' 'a' 'list', 'Discard first item'); 16 @include assert-equal(functions.list-slice($list, 2), 'is' 'a' 'list', 'Discard first item');
14 @include assert-equal(iro-list-slice($list, 1, 3), 'this' 'is' 'a', 'Keep first 3 items'); 17 @include assert-equal(functions.list-slice($list, 1, 3), 'this' 'is' 'a', 'Keep first 3 items');
15 @include assert-equal(iro-list-slice($list, 2, 3), 'is' 'a', 'Extract list from index 2 to 3'); 18 @include assert-equal(functions.list-slice($list, 2, 3), 'is' 'a', 'Extract list from index 2 to 3');
16 @include assert-equal(iro-list-slice($list, -1, -1), join((), 'list'), 'Keep last item'); 19 @include assert-equal(functions.list-slice($list, -1, -1), join((), 'list'), 'Keep last item');
17 @include assert-equal(iro-list-slice($list, -1, 1), 'list' 'this', 'Extract first and last item'); 20 @include assert-equal(functions.list-slice($list, -1, 1), 'list' 'this', 'Extract first and last item');
18 } 21 }
19 22
20 @include it('iro-list-prepend') { 23 @include it('list-prepend') {
21 $list: 'this' 'is' 'a' 'list'; 24 $list: 'this' 'is' 'a' 'list';
22 25
23 @include assert-equal(iro-list-prepend($list, 'and'), 'and' 'this' 'is' 'a' 'list', 'Prepend "and"'); 26 @include assert-equal(functions.list-prepend($list, 'and'), 'and' 'this' 'is' 'a' 'list', 'Prepend "and"');
24 @include assert-equal(iro-list-prepend($list, 2), 2 'this' 'is' 'a' 'list', 'Prepend 2'); 27 @include assert-equal(functions.list-prepend($list, 2), 2 'this' 'is' 'a' 'list', 'Prepend 2');
25 } 28 }
26 29
27 @include it('iro-quicksort') { 30 @include it('quicksort') {
28 @include assert-equal(iro-quicksort(1 2 3 4 5), 1 2 3 4 5, 'Already sorted list of 5 items'); 31 @include assert-equal(functions.quicksort(1 2 3 4 5), 1 2 3 4 5, 'Already sorted list of 5 items');
29 @include assert-equal(iro-quicksort(1 3 2), 1 2 3, 'Random list of 3 items'); 32 @include assert-equal(functions.quicksort(1 3 2), 1 2 3, 'Random list of 3 items');
30 @include assert-equal(iro-quicksort(6 3 7 3 8 1 4), 1 3 3 4 6 7 8, 'Random list of 7 items, one duplicate'); 33 @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');
31 @include assert-equal(iro-quicksort(1 1 1 1), 1 1 1 1, 'List of 4 identical items'); 34 @include assert-equal(functions.quicksort(1 1 1 1), 1 1 1 1, 'List of 4 identical items');
32 } 35 }
33 36
34 @include it('iro-map-get-default') { 37 @include it('map-get-default') {
35 $map: ('key': 'value', 'another': 'item'); 38 $map: ('key': 'value', 'another': 'item');
36 39
37 @include assert-equal(iro-map-get-default($map, 'another', 0), map-get($map, 'another'), 'Get existing value'); 40 @include assert-equal(functions.map-get-default($map, 'another', 0), map-get($map, 'another'), 'Get existing value');
38 @include assert-equal(iro-map-get-default($map, 'index', 'nothing'), 'nothing', 'Get missing value'); 41 @include assert-equal(functions.map-get-default($map, 'index', 'nothing'), 'nothing', 'Get missing value');
39 } 42 }
40 43
41 @include it('iro-map-get-deep') { 44 @include it('map-get-deep') {
42 $map: ( 45 $map: (
43 'key': 'value', 46 'key': 'value',
44 'sub': ( 47 'sub': (
@@ -51,14 +54,14 @@
51 ) 54 )
52 ); 55 );
53 56
54 @include assert-equal(iro-map-get-deep($map, 'key'), map-get($map, 'key'), 'Get value in root level'); 57 @include assert-equal(functions.map-get-deep($map, 'key'), map-get($map, 'key'), 'Get value in root level');
55 @include assert-equal(iro-map-get-deep($map, 'sub' 'item1'), map-get(map-get($map, 'sub'), 'item1'), 'Get value in first level'); 58 @include assert-equal(functions.map-get-deep($map, 'sub' 'item1'), map-get(map-get($map, 'sub'), 'item1'), 'Get value in first level');
56 @include assert-equal(iro-map-get-deep($map, 'sub' 'item2'), map-get(map-get($map, 'sub'), 'item2'), 'Get value in first level'); 59 @include assert-equal(functions.map-get-deep($map, 'sub' 'item2'), map-get(map-get($map, 'sub'), 'item2'), 'Get value in first level');
57 @include assert-equal(iro-map-get-deep($map, 'sub' 'subsub' 'item1'), map-get(map-get(map-get($map, 'sub'), 'subsub'), 'item1'), 'Get value in second level'); 60 @include assert-equal(functions.map-get-deep($map, 'sub' 'subsub' 'item1'), map-get(map-get(map-get($map, 'sub'), 'subsub'), 'item1'), 'Get value in second level');
58 @include assert-equal(iro-map-get-deep($map, 'sub' 'subsub' 'item2'), map-get(map-get(map-get($map, 'sub'), 'subsub'), 'item2'), 'Get value in second level'); 61 @include assert-equal(functions.map-get-deep($map, 'sub' 'subsub' 'item2'), map-get(map-get(map-get($map, 'sub'), 'subsub'), 'item2'), 'Get value in second level');
59 } 62 }
60 63
61 @include it('iro-map-merge-recursive') { 64 @include it('map-merge-recursive') {
62 $map1: ( 65 $map1: (
63 'key': 'value', 66 'key': 'value',
64 'sub': ( 67 'sub': (
@@ -84,20 +87,20 @@
84 ) 87 )
85 ); 88 );
86 89
87 @include assert-equal(iro-map-merge-recursive($map1, $map2), $expected); 90 @include assert-equal(functions.map-merge-recursive($map1, $map2), $expected);
88 } 91 }
89 92
90 @include it('iro-strip-unit') { 93 @include it('strip-unit') {
91 @include assert-true(unitless(iro-strip-unit(1em)), 'Remove unit from 1em'); 94 @include assert-true(unitless(functions.strip-unit(1em)), 'Remove unit from 1em');
92 @include assert-true(unitless(iro-strip-unit(2rem)), 'Remove unit from 2rem'); 95 @include assert-true(unitless(functions.strip-unit(2rem)), 'Remove unit from 2rem');
93 @include assert-true(unitless(iro-strip-unit(3px)), 'Remove unit from 3px'); 96 @include assert-true(unitless(functions.strip-unit(3px)), 'Remove unit from 3px');
94 @include assert-true(unitless(iro-strip-unit(4)), 'Remove unit from 4'); 97 @include assert-true(unitless(functions.strip-unit(4)), 'Remove unit from 4');
95 @include assert-true(unitless(iro-strip-unit(5pt)), 'Remove unit from 5pt'); 98 @include assert-true(unitless(functions.strip-unit(5pt)), 'Remove unit from 5pt');
96 } 99 }
97 100
98 @include it('iro-px-to-rem') { 101 @include it('px-to-rem') {
99 @include assert-equal(iro-px-to-rem(16px, 16px), 1rem, 'Convert 16px'); 102 @include assert-equal(functions.px-to-rem(16px, 16px), 1rem, 'Convert 16px');
100 @include assert-equal(iro-px-to-rem(32px, 16px), 2rem, 'Convert 16px'); 103 @include assert-equal(functions.px-to-rem(32px, 16px), 2rem, 'Convert 16px');
101 @include assert-equal(iro-px-to-rem(8px, 16px), 0.5rem, 'Convert 16px'); 104 @include assert-equal(functions.px-to-rem(8px, 16px), 0.5rem, 'Convert 16px');
102 } 105 }
103} 106}