diff options
author | Volpeon <git@volpeon.ink> | 2021-03-17 17:32:14 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2021-03-17 17:32:14 +0100 |
commit | 8f2ce6e4491d630a35dca9612daedf95b4a2954b (patch) | |
tree | 037ca6c1fd40a8c424328ad3392fe6edfaad175c /test | |
parent | Expose prefix parameter for iro-props-assign-native (diff) | |
download | iro-sass-8f2ce6e4491d630a35dca9612daedf95b4a2954b.tar.gz iro-sass-8f2ce6e4491d630a35dca9612daedf95b4a2954b.tar.bz2 iro-sass-8f2ce6e4491d630a35dca9612daedf95b4a2954b.zip |
Added namespaces and shortcodes for property trees
Diffstat (limited to 'test')
-rw-r--r-- | test/_props.scss | 166 |
1 files changed, 87 insertions, 79 deletions
diff --git a/test/_props.scss b/test/_props.scss index 4e0a5b4..982fc2f 100644 --- a/test/_props.scss +++ b/test/_props.scss | |||
@@ -36,16 +36,12 @@ | |||
36 | --primary: ( | 36 | --primary: ( |
37 | --background: #f00, | 37 | --background: #f00, |
38 | --text: #fff | 38 | --text: #fff |
39 | ), | ||
40 | --default: ( | ||
41 | --background: #ddd, | ||
42 | --text: #000 | ||
43 | ) | 39 | ) |
44 | ) | 40 | ) |
45 | ); | 41 | ); |
46 | 42 | ||
47 | @include assert-equal(iro-props-save($map), null, 'Save default tree'); | 43 | @include assert-equal(iro-props-store($map), null, 'Save default tree'); |
48 | @include assert-equal(iro-props-delete(), null, 'Delete default tree'); | 44 | @include assert-equal(iro-props-clear(), null, 'Delete default tree'); |
49 | } | 45 | } |
50 | 46 | ||
51 | @include it('Read') { | 47 | @include it('Read') { |
@@ -56,10 +52,6 @@ | |||
56 | --primary: ( | 52 | --primary: ( |
57 | --background: #f00, | 53 | --background: #f00, |
58 | --text: #fff | 54 | --text: #fff |
59 | ), | ||
60 | --default: ( | ||
61 | --background: #ddd, | ||
62 | --text: #000 | ||
63 | ) | 55 | ) |
64 | ) | 56 | ) |
65 | ); | 57 | ); |
@@ -71,35 +63,52 @@ | |||
71 | --primary: ( | 63 | --primary: ( |
72 | --background: #f00, | 64 | --background: #f00, |
73 | --text: #fff | 65 | --text: #fff |
74 | ), | ||
75 | --default: ( | ||
76 | --background: #444, | ||
77 | --text: #fff | ||
78 | ) | 66 | ) |
79 | ) | 67 | ) |
80 | ); | 68 | ); |
81 | 69 | ||
82 | @include assert-equal(iro-props-save($map1), null, 'Save default tree'); | 70 | $map3: ( |
83 | @include assert-equal(iro-props-save($map2, 'test'), null, 'Save "test" tree'); | 71 | --background: #666, |
72 | --text: #222, | ||
73 | --buttons: ( | ||
74 | --primary: ( | ||
75 | --background: #0f0, | ||
76 | --text: #000 | ||
77 | ) | ||
78 | ) | ||
79 | ); | ||
80 | |||
81 | @include assert-equal(iro-props-store($map1), null, 'Save default tree'); | ||
82 | @include assert-equal(iro-props-store($map2, 'test'), null, 'Save "test" tree'); | ||
83 | |||
84 | @include iro-props-namespace('ns') { | ||
85 | @include assert-equal(iro-props-store($map3, 'namespaced'), null, 'Save "namespaced" tree'); | ||
86 | } | ||
84 | 87 | ||
85 | @include assert-equal(iro-props-get(--background), map-get($map1, --background), 'Get --background in default'); | 88 | @include assert-equal(iro-props-get(--background), map-get($map1, --background), 'Get --background in default'); |
86 | @include assert-equal(iro-props-get(--buttons --primary --background), map-get(map-get(map-get($map1, --buttons), --primary), --background), 'Get --buttons --primary --background in default'); | 89 | @include assert-equal(iro-props-get(--buttons --primary --background), map-get(map-get(map-get($map1, --buttons), --primary), --background), 'Get --buttons --primary --background in default'); |
87 | @include assert-equal(iro-props-get(--buttons --default --text), map-get(map-get(map-get($map1, --buttons), --default), --text), 'Get --buttons --default --text in default'); | ||
88 | @include assert-equal(iro-props-get(--box, $default: false), false, 'Get nonexistent in default'); | 90 | @include assert-equal(iro-props-get(--box, $default: false), false, 'Get nonexistent in default'); |
89 | 91 | ||
90 | @include assert-equal(iro-props-get(--background, 'test'), map-get($map2, --background), 'Get --background in "test"'); | 92 | @include assert-equal(iro-props-get(--background, 'test'), map-get($map2, --background), 'Get --background in "test"'); |
91 | @include assert-equal(iro-props-get(--buttons --primary --background, 'test'), map-get(map-get(map-get($map2, --buttons), --primary), --background), 'Get --buttons --primary --background in "test"'); | 93 | @include assert-equal(iro-props-get(--buttons --primary --background, 'test'), map-get(map-get(map-get($map2, --buttons), --primary), --background), 'Get --buttons --primary --background in "test"'); |
92 | @include assert-equal(iro-props-get(--buttons --default --text, 'test'), map-get(map-get(map-get($map2, --buttons), --default), --text), 'Get --buttons --default --text in "test"'); | ||
93 | @include assert-equal(iro-props-get(--box, 'test', $default: false), false, 'Get nonexistent in "test"'); | 94 | @include assert-equal(iro-props-get(--box, 'test', $default: false), false, 'Get nonexistent in "test"'); |
95 | |||
96 | @include assert-equal(iro-props-get(--background, 'namespaced', $default: false), false, 'Get --background in "namespaced"'); | ||
97 | @include assert-equal(iro-props-get(--ns --background, 'namespaced'), map-get($map3, --background), 'Get --ns --background in "namespaced"'); | ||
98 | @include iro-props-namespace('ns') { | ||
99 | @include assert-equal(iro-props-get(--background, 'namespaced'), map-get($map3, --background), 'Get namespaced --background in "namespaced"'); | ||
100 | @include assert-equal(iro-props-get(--buttons --primary --background, 'namespaced'), map-get(map-get(map-get($map3, --buttons), --primary), --background), 'Get namespaced --buttons --primary --background in "namespaced"'); | ||
101 | @include assert-equal(iro-props-get(--box, 'namespaced', $default: false), false, 'Get namespaced nonexistent in "namespaced"'); | ||
102 | } | ||
94 | 103 | ||
95 | @include assert-equal(iro-props-delete(), null, 'Delete default tree'); | 104 | @include assert-equal(iro-props-clear(), null, 'Delete default tree'); |
96 | @include assert-equal(iro-props-delete('test'), null, 'Delete "test" tree'); | 105 | @include assert-equal(iro-props-clear('test'), null, 'Delete "test" tree'); |
106 | @include assert-equal(iro-props-clear('namespaced'), null, 'Delete "namespaced" tree'); | ||
97 | } | 107 | } |
98 | 108 | ||
99 | @include it('Overwrite') { | 109 | @include it('Overwrite') { |
100 | $map1: ( | 110 | $map1: ( |
101 | --background: #fff, | 111 | --background: #fff, |
102 | --text: #000, | ||
103 | --buttons: ( | 112 | --buttons: ( |
104 | --primary: ( | 113 | --primary: ( |
105 | --background: #f00, | 114 | --background: #f00, |
@@ -110,54 +119,43 @@ | |||
110 | 119 | ||
111 | $map2: ( | 120 | $map2: ( |
112 | --background: #eee, | 121 | --background: #eee, |
122 | --text: #000, | ||
113 | --buttons: ( | 123 | --buttons: ( |
114 | --primary: ( | 124 | --primary: ( |
115 | --background: #00f | 125 | --background: #00f |
116 | ), | ||
117 | --default: ( | ||
118 | --background: #444, | ||
119 | --text: #fff | ||
120 | ) | 126 | ) |
121 | ) | 127 | ) |
122 | ); | 128 | ); |
123 | 129 | ||
124 | @include assert-equal(iro-props-save($map1), null, 'Save default tree'); | 130 | @include assert-equal(iro-props-store($map1), null, 'Save default tree'); |
125 | 131 | @include assert-equal(iro-props-store($map2, $merge: true), null, 'Overwrite default tree'); | |
126 | @include assert-equal(iro-props-get(), $map1, 'Before update, get whole map'); | ||
127 | @include assert-equal(iro-props-get(--background), map-get($map1, --background), 'Before update, get --background'); | ||
128 | @include assert-equal(iro-props-get(--text), map-get($map1, --text), 'Before update, get --text'); | ||
129 | @include assert-equal(iro-props-get(--buttons --primary --background), map-get(map-get(map-get($map1, --buttons), --primary), --background), 'Before update, get --buttons --primary --background'); | ||
130 | @include assert-equal(iro-props-get(--buttons --default --text, $default: false), false, 'Before update, get --buttons --default --text (returns default)'); | ||
131 | |||
132 | @include assert-equal(iro-props-save($map2, $merge: true), null, 'Overwrite default tree'); | ||
133 | 132 | ||
134 | @include assert-equal(iro-props-get(), iro-map-merge-recursive($map1, $map2), 'After update, get whole map'); | 133 | @include assert-equal(iro-props-get(), iro-map-merge-recursive($map1, $map2), 'After update, get whole map'); |
135 | @include assert-equal(iro-props-get(--background), map-get($map2, --background), 'After update, get --background'); | 134 | @include assert-equal(iro-props-get(--background), map-get($map2, --background), 'After update, get --background'); |
136 | @include assert-equal(iro-props-get(--text), map-get($map1, --text), 'After update, get --text'); | 135 | @include assert-equal(iro-props-get(--text), map-get($map2, --text), 'After update, get --text'); |
137 | @include assert-equal(iro-props-get(--buttons --primary --background), map-get(map-get(map-get($map2, --buttons), --primary), --background), 'After update, get --buttons --primary --background'); | 136 | @include assert-equal(iro-props-get(--buttons --primary --text), map-get(map-get(map-get($map1, --buttons), --primary), --text), 'After update, get --buttons --primary --text'); |
138 | @include assert-equal(iro-props-get(--buttons --default --text), map-get(map-get(map-get($map2, --buttons), --default), --text), 'After update, get --buttons --default --text'); | ||
139 | 137 | ||
140 | @include assert-equal(iro-props-delete(), null, 'Delete default tree'); | 138 | @include assert-equal(iro-props-clear(), null, 'Delete default tree'); |
141 | } | 139 | } |
142 | 140 | ||
143 | @include it('Native assignment') { | 141 | @include it('Native assignment') { |
144 | @include assert('Simple') { | 142 | $map: ( |
145 | $map: ( | 143 | --background: #fff, |
146 | --background: #fff, | 144 | --text: #000, |
147 | --text: #000, | 145 | --buttons: ( |
148 | --buttons: ( | 146 | --primary: ( |
149 | --primary: ( | 147 | --background: #f00, |
150 | --background: #f00, | 148 | --text: #fff |
151 | --text: #fff | 149 | ), |
152 | ), | 150 | --default: ( |
153 | --default: ( | 151 | --background: #ddd, |
154 | --background: #ddd, | 152 | --text: #000 |
155 | --text: #000 | ||
156 | ) | ||
157 | ) | 153 | ) |
158 | ); | 154 | ) |
155 | ); | ||
159 | 156 | ||
160 | @include iro-props-save($map); | 157 | @include assert('Simple') { |
158 | @include iro-props-store($map); | ||
161 | 159 | ||
162 | @include output { | 160 | @include output { |
163 | @include iro-props-assign-native; | 161 | @include iro-props-assign-native; |
@@ -172,26 +170,11 @@ | |||
172 | --buttons--default--text: #{map-get(map-get(map-get($map, --buttons), --default), --text)}; | 170 | --buttons--default--text: #{map-get(map-get(map-get($map, --buttons), --default), --text)}; |
173 | } | 171 | } |
174 | 172 | ||
175 | @include iro-props-delete; | 173 | @include iro-props-clear; |
176 | } | 174 | } |
177 | 175 | ||
178 | @include assert('Filtered') { | 176 | @include assert('Filtered') { |
179 | $map: ( | 177 | @include iro-props-store($map); |
180 | --background: #fff, | ||
181 | --text: #000, | ||
182 | --buttons: ( | ||
183 | --primary: ( | ||
184 | --background: #f00, | ||
185 | --text: #fff | ||
186 | ), | ||
187 | --default: ( | ||
188 | --background: #ddd, | ||
189 | --text: #000 | ||
190 | ) | ||
191 | ) | ||
192 | ); | ||
193 | |||
194 | @include iro-props-save($map); | ||
195 | 178 | ||
196 | @include output { | 179 | @include output { |
197 | @include iro-props-assign-native($skip: --buttons); | 180 | @include iro-props-assign-native($skip: --buttons); |
@@ -202,7 +185,28 @@ | |||
202 | --text: #{map-get($map, --text)}; | 185 | --text: #{map-get($map, --text)}; |
203 | } | 186 | } |
204 | 187 | ||
205 | @include iro-props-delete; | 188 | @include iro-props-clear; |
189 | } | ||
190 | |||
191 | @include assert('Namespaced') { | ||
192 | @include iro-props-namespace('ns') { | ||
193 | @include iro-props-store($map); | ||
194 | } | ||
195 | |||
196 | @include output { | ||
197 | @include iro-props-assign-native; | ||
198 | } | ||
199 | |||
200 | @include expect { | ||
201 | --ns--background: #{map-get($map, --background)}; | ||
202 | --ns--text: #{map-get($map, --text)}; | ||
203 | --ns--buttons--primary--background: #{map-get(map-get(map-get($map, --buttons), --primary), --background)}; | ||
204 | --ns--buttons--primary--text: #{map-get(map-get(map-get($map, --buttons), --primary), --text)}; | ||
205 | --ns--buttons--default--background: #{map-get(map-get(map-get($map, --buttons), --default), --background)}; | ||
206 | --ns--buttons--default--text: #{map-get(map-get(map-get($map, --buttons), --default), --text)}; | ||
207 | } | ||
208 | |||
209 | @include iro-props-clear; | ||
206 | } | 210 | } |
207 | } | 211 | } |
208 | 212 | ||
@@ -222,13 +226,17 @@ | |||
222 | ) | 226 | ) |
223 | ); | 227 | ); |
224 | 228 | ||
225 | @include assert-equal(iro-props-save($map), null, 'Save default tree'); | 229 | @include assert-equal(iro-props-store($map), null, 'Save default tree'); |
226 | 230 | ||
227 | @include assert-equal(iro-props-get-native(--background), var(--background), 'Get --background'); | 231 | @include assert-equal(iro-props-get-native(--background), var(--background), 'Get --background'); |
228 | @include assert-equal(iro-props-get-native(--buttons --primary --text), var(--buttons--primary--text), 'Get --buttons --primary --text'); | 232 | @include assert-equal(iro-props-get-native(--buttons --primary --text), var(--buttons--primary--text), 'Get --buttons --primary --text'); |
229 | @include assert-equal(iro-props-get-native(--buttons --secondary --text, $default: false), var(--buttons--secondary--text, false), 'Get --buttons --secondary --text with default'); | 233 | @include assert-equal(iro-props-get-native(--buttons --secondary --text, $default: false), var(--buttons--secondary--text, false), 'Get --buttons --secondary --text with default'); |
234 | @include iro-props-namespace('buttons') { | ||
235 | @include assert-equal(iro-props-get-native(--primary --text), var(--buttons--primary--text), 'Get via namespace "buttons" --primary --text'); | ||
236 | @include assert-equal(iro-props-get-native(--secondary --text, $default: false), var(--buttons--secondary--text, false), 'Get via namespace "buttons" --secondary --text with default'); | ||
237 | } | ||
230 | 238 | ||
231 | @include assert-equal(iro-props-delete(), null, 'Delete default tree'); | 239 | @include assert-equal(iro-props-clear(), null, 'Delete default tree'); |
232 | } | 240 | } |
233 | 241 | ||
234 | @include it('References') { | 242 | @include it('References') { |
@@ -253,8 +261,8 @@ | |||
253 | ) | 261 | ) |
254 | ); | 262 | ); |
255 | 263 | ||
256 | @include assert-equal(iro-props-save($map1), null, 'Save default tree'); | 264 | @include assert-equal(iro-props-store($map1), null, 'Save default tree'); |
257 | @include assert-equal(iro-props-save($map2, 'second'), null, 'Save "second" tree'); | 265 | @include assert-equal(iro-props-store($map2, 'second'), null, 'Save "second" tree'); |
258 | 266 | ||
259 | @include assert-equal(iro-props-get(--buttons --primary --background, 'second'), map-get($map1, --background), 'Get referenced value'); | 267 | @include assert-equal(iro-props-get(--buttons --primary --background, 'second'), map-get($map1, --background), 'Get referenced value'); |
260 | @include assert-equal(iro-props-get-native(--buttons --primary --background, 'second'), var(--buttons--primary--background), 'Get referenced value, native'); | 268 | @include assert-equal(iro-props-get-native(--buttons --primary --background, 'second'), var(--buttons--primary--background), 'Get referenced value, native'); |
@@ -276,7 +284,7 @@ | |||
276 | } | 284 | } |
277 | } | 285 | } |
278 | 286 | ||
279 | @include assert-equal(iro-props-delete(), null, 'Delete default tree'); | 287 | @include assert-equal(iro-props-clear(), null, 'Delete default tree'); |
280 | @include assert-equal(iro-props-delete('second'), null, 'Delete "second" tree'); | 288 | @include assert-equal(iro-props-clear('second'), null, 'Delete "second" tree'); |
281 | } | 289 | } |
282 | } | 290 | } |