aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/_functions.scss49
-rw-r--r--test/_props.scss53
2 files changed, 27 insertions, 75 deletions
diff --git a/test/_functions.scss b/test/_functions.scss
index 2430f28..07561ef 100644
--- a/test/_functions.scss
+++ b/test/_functions.scss
@@ -41,55 +41,6 @@
41 @include assert-equal(functions.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');
42 } 42 }
43 43
44 @include it('map-get-deep') {
45 $map: (
46 'key': 'value',
47 'sub': (
48 'item1': 1,
49 'item2': 2,
50 'subsub': (
51 'item1': 11,
52 'item2': 12,
53 )
54 )
55 );
56
57 @include assert-equal(functions.map-get-deep($map, 'key'), map-get($map, 'key'), 'Get value in root level');
58 @include assert-equal(functions.map-get-deep($map, 'sub' 'item1'), map-get(map-get($map, 'sub'), 'item1'), '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');
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');
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');
62 }
63
64 @include it('map-merge-recursive') {
65 $map1: (
66 'key': 'value',
67 'sub': (
68 'item1': 1,
69 'item3': 2
70 )
71 );
72 $map2: (
73 'another': 'item',
74 'sub': (
75 'item1': 0,
76 'item2': 1
77 )
78 );
79
80 $expected: (
81 'key': 'value',
82 'another': 'item',
83 'sub': (
84 'item1': 0,
85 'item2': 1,
86 'item3': 2
87 )
88 );
89
90 @include assert-equal(functions.map-merge-recursive($map1, $map2), $expected);
91 }
92
93 @include it('strip-unit') { 44 @include it('strip-unit') {
94 @include assert-true(unitless(functions.strip-unit(1em)), 'Remove unit from 1em'); 45 @include assert-true(unitless(functions.strip-unit(1em)), 'Remove unit from 1em');
95 @include assert-true(unitless(functions.strip-unit(2rem)), 'Remove unit from 2rem'); 46 @include assert-true(unitless(functions.strip-unit(2rem)), 'Remove unit from 2rem');
diff --git a/test/_props.scss b/test/_props.scss
index 71d88c5..d8b550b 100644
--- a/test/_props.scss
+++ b/test/_props.scss
@@ -1,5 +1,6 @@
1// sass-lint:disable empty-args 1// sass-lint:disable empty-args
2 2
3@use 'sass:map';
3@use 'true' as *; 4@use 'true' as *;
4@use '../src/functions'; 5@use '../src/functions';
5@use '../src/props'; 6@use '../src/props';
@@ -89,20 +90,20 @@
89 @include assert-equal(props.store($map3, 'namespaced'), null, 'Save "namespaced" tree'); 90 @include assert-equal(props.store($map3, 'namespaced'), null, 'Save "namespaced" tree');
90 } 91 }
91 92
92 @include assert-equal(props.get-static(--background), map-get($map1, --background), 'Get --background in default'); 93 @include assert-equal(props.get-static(--background), map-get($map1, --background), 'Get --background in default');
93 @include assert-equal(props.get-static(--buttons --primary --background), map-get(map-get(map-get($map1, --buttons), --primary), --background), 'Get --buttons --primary --background in default'); 94 @include assert-equal(props.get-static(--buttons --primary --background), map-get($map1, --buttons, --primary, --background), 'Get --buttons --primary --background in default');
94 @include assert-equal(props.get-static(--box, $default: false), false, 'Get nonexistent in default'); 95 @include assert-equal(props.get-static(--box, $default: false), false, 'Get nonexistent in default');
95 96
96 @include assert-equal(props.get-static(--background, 'test'), map-get($map2, --background), 'Get --background in "test"'); 97 @include assert-equal(props.get-static(--background, 'test'), map-get($map2, --background), 'Get --background in "test"');
97 @include assert-equal(props.get-static(--buttons --primary --background, 'test'), map-get(map-get(map-get($map2, --buttons), --primary), --background), 'Get --buttons --primary --background in "test"'); 98 @include assert-equal(props.get-static(--buttons --primary --background, 'test'), map-get($map2, --buttons, --primary, --background), 'Get --buttons --primary --background in "test"');
98 @include assert-equal(props.get-static(--box, 'test', $default: false), false, 'Get nonexistent in "test"'); 99 @include assert-equal(props.get-static(--box, 'test', $default: false), false, 'Get nonexistent in "test"');
99 100
100 @include assert-equal(props.get-static(--background, 'namespaced', $default: false), false, 'Get --background in "namespaced"'); 101 @include assert-equal(props.get-static(--background, 'namespaced', $default: false), false, 'Get --background in "namespaced"');
101 @include assert-equal(props.get-static(--ns --background, 'namespaced'), map-get($map3, --background), 'Get --ns --background in "namespaced"'); 102 @include assert-equal(props.get-static(--ns --background, 'namespaced'), map-get($map3, --background), 'Get --ns --background in "namespaced"');
102 @include props.namespace('ns') { 103 @include props.namespace('ns') {
103 @include assert-equal(props.get-static(--background, 'namespaced'), map-get($map3, --background), 'Get namespaced --background in "namespaced"'); 104 @include assert-equal(props.get-static(--background, 'namespaced'), map-get($map3, --background), 'Get namespaced --background in "namespaced"');
104 @include assert-equal(props.get-static(--buttons --primary --background, 'namespaced'), map-get(map-get(map-get($map3, --buttons), --primary), --background), 'Get namespaced --buttons --primary --background in "namespaced"'); 105 @include assert-equal(props.get-static(--buttons --primary --background, 'namespaced'), map-get($map3, --buttons, --primary, --background), 'Get namespaced --buttons --primary --background in "namespaced"');
105 @include assert-equal(props.get-static(--box, 'namespaced', $default: false), false, 'Get namespaced nonexistent in "namespaced"'); 106 @include assert-equal(props.get-static(--box, 'namespaced', $default: false), false, 'Get namespaced nonexistent in "namespaced"');
106 } 107 }
107 108
108 @include assert-equal(props.clear(), null, 'Delete default tree'); 109 @include assert-equal(props.clear(), null, 'Delete default tree');
@@ -134,10 +135,10 @@
134 @include assert-equal(props.store($map1), null, 'Save default tree'); 135 @include assert-equal(props.store($map1), null, 'Save default tree');
135 @include assert-equal(props.store($map2, $merge: true), null, 'Overwrite default tree'); 136 @include assert-equal(props.store($map2, $merge: true), null, 'Overwrite default tree');
136 137
137 @include assert-equal(props.get-static(), functions.map-merge-recursive($map1, $map2), 'After update, get whole map'); 138 @include assert-equal(props.get-static(), map.deep-merge($map1, $map2), 'After update, get whole map');
138 @include assert-equal(props.get-static(--background), map-get($map2, --background), 'After update, get --background'); 139 @include assert-equal(props.get-static(--background), map-get($map2, --background), 'After update, get --background');
139 @include assert-equal(props.get-static(--text), map-get($map2, --text), 'After update, get --text'); 140 @include assert-equal(props.get-static(--text), map-get($map2, --text), 'After update, get --text');
140 @include assert-equal(props.get-static(--buttons --primary --text), map-get(map-get(map-get($map1, --buttons), --primary), --text), 'After update, get --buttons --primary --text'); 141 @include assert-equal(props.get-static(--buttons --primary --text), map-get($map1, --buttons, --primary, --text), 'After update, get --buttons --primary --text');
141 142
142 @include assert-equal(props.clear(), null, 'Delete default tree'); 143 @include assert-equal(props.clear(), null, 'Delete default tree');
143 } 144 }
@@ -168,10 +169,10 @@
168 @include expect { 169 @include expect {
169 --background: #{map-get($map, --background)}; 170 --background: #{map-get($map, --background)};
170 --text: #{map-get($map, --text)}; 171 --text: #{map-get($map, --text)};
171 --buttons--primary--background: #{map-get(map-get(map-get($map, --buttons), --primary), --background)}; 172 --buttons--primary--background: #{map-get($map, --buttons, --primary, --background)};
172 --buttons--primary--text: #{map-get(map-get(map-get($map, --buttons), --primary), --text)}; 173 --buttons--primary--text: #{map-get($map, --buttons, --primary, --text)};
173 --buttons--default--background: #{map-get(map-get(map-get($map, --buttons), --default), --background)}; 174 --buttons--default--background: #{map-get($map, --buttons, --default, --background)};
174 --buttons--default--text: #{map-get(map-get(map-get($map, --buttons), --default), --text)}; 175 --buttons--default--text: #{map-get($map, --buttons, --default, --text)};
175 } 176 }
176 177
177 @include props.clear; 178 @include props.clear;
@@ -204,10 +205,10 @@
204 @include expect { 205 @include expect {
205 --ns--background: #{map-get($map, --background)}; 206 --ns--background: #{map-get($map, --background)};
206 --ns--text: #{map-get($map, --text)}; 207 --ns--text: #{map-get($map, --text)};
207 --ns--buttons--primary--background: #{map-get(map-get(map-get($map, --buttons), --primary), --background)}; 208 --ns--buttons--primary--background: #{map-get($map, --buttons, --primary, --background)};
208 --ns--buttons--primary--text: #{map-get(map-get(map-get($map, --buttons), --primary), --text)}; 209 --ns--buttons--primary--text: #{map-get($map, --buttons, --primary, --text)};
209 --ns--buttons--default--background: #{map-get(map-get(map-get($map, --buttons), --default), --background)}; 210 --ns--buttons--default--background: #{map-get($map, --buttons, --default, --background)};
210 --ns--buttons--default--text: #{map-get(map-get(map-get($map, --buttons), --default), --text)}; 211 --ns--buttons--default--text: #{map-get($map, --buttons, --default, --text)};
211 } 212 }
212 213
213 @include props.clear; 214 @include props.clear;
@@ -271,9 +272,9 @@
271 @include assert-equal(props.get-static(--buttons --primary --background, 'second'), map-get($map1, --background), 'Get referenced value'); 272 @include assert-equal(props.get-static(--buttons --primary --background, 'second'), map-get($map1, --background), 'Get referenced value');
272 @include assert-equal(props.get(--buttons --primary --background, 'second'), var(--buttons--primary--background), 'Get referenced value, native'); 273 @include assert-equal(props.get(--buttons --primary --background, 'second'), var(--buttons--primary--background), 'Get referenced value, native');
273 274
274 @include assert-equal(props.get-static(--buttons --default, 'second'), map-get(map-get($map1, --buttons), --primary), 'Get referenced subtree, whole'); 275 @include assert-equal(props.get-static(--buttons --default, 'second'), map-get($map1, --buttons, --primary), 'Get referenced subtree, whole');
275 @include assert-equal(props.get-static(--buttons --default --background, 'second'), map-get(map-get(map-get($map1, --buttons), --primary), --background), 'Get referenced subtree, inner value'); 276 @include assert-equal(props.get-static(--buttons --default --background, 'second'), map-get($map1, --buttons, --primary, --background), 'Get referenced subtree, inner value');
276 @include assert-equal(props.get(--buttons --default --background, 'second'), var(--buttons--default--background), 'Get referenced subtree, native'); 277 @include assert-equal(props.get(--buttons --default --background, 'second'), var(--buttons--default--background), 'Get referenced subtree, native');
277 278
278 @include assert('Native assignment') { 279 @include assert('Native assignment') {
279 @include output { 280 @include output {
@@ -283,8 +284,8 @@
283 @include expect { 284 @include expect {
284 --background: #{map-get($map2, --background)}; 285 --background: #{map-get($map2, --background)};
285 --buttons--primary--background: #{map-get($map1, --background)}; 286 --buttons--primary--background: #{map-get($map1, --background)};
286 --buttons--default--background: #{map-get(map-get(map-get($map1, --buttons), --primary), --background)}; 287 --buttons--default--background: #{map-get($map1, --buttons, --primary, --background)};
287 --buttons--default--text: #{map-get(map-get(map-get($map1, --buttons), --primary), --text)}; 288 --buttons--default--text: #{map-get($map1, --buttons, --primary, --text)};
288 } 289 }
289 } 290 }
290 291