From dd5f3c463fab336d694f426dcad11a1783590fc9 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 5 Feb 2022 07:52:13 +0100 Subject: Ported from import syntax to modules --- test/_props.scss | 124 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 60 deletions(-) (limited to 'test/_props.scss') diff --git a/test/_props.scss b/test/_props.scss index 021ed4c..71d88c5 100644 --- a/test/_props.scss +++ b/test/_props.scss @@ -1,5 +1,9 @@ // sass-lint:disable empty-args +@use 'true' as *; +@use '../src/functions'; +@use '../src/props'; + @include describe('Property trees') { @include it('Validate names') { $map-valid: ( @@ -24,8 +28,8 @@ ) ); - @include assert-equal(iro-props-validate($map-valid), true, 'Check valid map'); - @include assert-equal(iro-props-validate($map-invalid), false, 'Check invalid map'); + @include assert-equal(props.validate($map-valid), true, 'Check valid map'); + @include assert-equal(props.validate($map-invalid), false, 'Check invalid map'); } @include it('Save / Delete') { @@ -40,8 +44,8 @@ ) ); - @include assert-equal(iro-props-store($map), null, 'Save default tree'); - @include assert-equal(iro-props-clear(), null, 'Delete default tree'); + @include assert-equal(props.store($map), null, 'Save default tree'); + @include assert-equal(props.clear(), null, 'Delete default tree'); } @include it('Read') { @@ -78,32 +82,32 @@ ) ); - @include assert-equal(iro-props-store($map1), null, 'Save default tree'); - @include assert-equal(iro-props-store($map2, 'test'), null, 'Save "test" tree'); + @include assert-equal(props.store($map1), null, 'Save default tree'); + @include assert-equal(props.store($map2, 'test'), null, 'Save "test" tree'); - @include iro-props-namespace('ns') { - @include assert-equal(iro-props-store($map3, 'namespaced'), null, 'Save "namespaced" tree'); + @include props.namespace('ns') { + @include assert-equal(props.store($map3, 'namespaced'), null, 'Save "namespaced" tree'); } - @include assert-equal(iro-props-get-static(--background), map-get($map1, --background), 'Get --background in default'); - @include assert-equal(iro-props-get-static(--buttons --primary --background), map-get(map-get(map-get($map1, --buttons), --primary), --background), 'Get --buttons --primary --background in default'); - @include assert-equal(iro-props-get-static(--box, $default: false), false, 'Get nonexistent in default'); + @include assert-equal(props.get-static(--background), map-get($map1, --background), 'Get --background in default'); + @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'); + @include assert-equal(props.get-static(--box, $default: false), false, 'Get nonexistent in default'); - @include assert-equal(iro-props-get-static(--background, 'test'), map-get($map2, --background), 'Get --background in "test"'); - @include assert-equal(iro-props-get-static(--buttons --primary --background, 'test'), map-get(map-get(map-get($map2, --buttons), --primary), --background), 'Get --buttons --primary --background in "test"'); - @include assert-equal(iro-props-get-static(--box, 'test', $default: false), false, 'Get nonexistent in "test"'); + @include assert-equal(props.get-static(--background, 'test'), map-get($map2, --background), 'Get --background in "test"'); + @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"'); + @include assert-equal(props.get-static(--box, 'test', $default: false), false, 'Get nonexistent in "test"'); - @include assert-equal(iro-props-get-static(--background, 'namespaced', $default: false), false, 'Get --background in "namespaced"'); - @include assert-equal(iro-props-get-static(--ns --background, 'namespaced'), map-get($map3, --background), 'Get --ns --background in "namespaced"'); - @include iro-props-namespace('ns') { - @include assert-equal(iro-props-get-static(--background, 'namespaced'), map-get($map3, --background), 'Get namespaced --background in "namespaced"'); - @include assert-equal(iro-props-get-static(--buttons --primary --background, 'namespaced'), map-get(map-get(map-get($map3, --buttons), --primary), --background), 'Get namespaced --buttons --primary --background in "namespaced"'); - @include assert-equal(iro-props-get-static(--box, 'namespaced', $default: false), false, 'Get namespaced nonexistent in "namespaced"'); + @include assert-equal(props.get-static(--background, 'namespaced', $default: false), false, 'Get --background in "namespaced"'); + @include assert-equal(props.get-static(--ns --background, 'namespaced'), map-get($map3, --background), 'Get --ns --background in "namespaced"'); + @include props.namespace('ns') { + @include assert-equal(props.get-static(--background, 'namespaced'), map-get($map3, --background), 'Get namespaced --background in "namespaced"'); + @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"'); + @include assert-equal(props.get-static(--box, 'namespaced', $default: false), false, 'Get namespaced nonexistent in "namespaced"'); } - @include assert-equal(iro-props-clear(), null, 'Delete default tree'); - @include assert-equal(iro-props-clear('test'), null, 'Delete "test" tree'); - @include assert-equal(iro-props-clear('namespaced'), null, 'Delete "namespaced" tree'); + @include assert-equal(props.clear(), null, 'Delete default tree'); + @include assert-equal(props.clear('test'), null, 'Delete "test" tree'); + @include assert-equal(props.clear('namespaced'), null, 'Delete "namespaced" tree'); } @include it('Overwrite') { @@ -127,15 +131,15 @@ ) ); - @include assert-equal(iro-props-store($map1), null, 'Save default tree'); - @include assert-equal(iro-props-store($map2, $merge: true), null, 'Overwrite default tree'); + @include assert-equal(props.store($map1), null, 'Save default tree'); + @include assert-equal(props.store($map2, $merge: true), null, 'Overwrite default tree'); - @include assert-equal(iro-props-get-static(), iro-map-merge-recursive($map1, $map2), 'After update, get whole map'); - @include assert-equal(iro-props-get-static(--background), map-get($map2, --background), 'After update, get --background'); - @include assert-equal(iro-props-get-static(--text), map-get($map2, --text), 'After update, get --text'); - @include assert-equal(iro-props-get-static(--buttons --primary --text), map-get(map-get(map-get($map1, --buttons), --primary), --text), 'After update, get --buttons --primary --text'); + @include assert-equal(props.get-static(), functions.map-merge-recursive($map1, $map2), 'After update, get whole map'); + @include assert-equal(props.get-static(--background), map-get($map2, --background), 'After update, get --background'); + @include assert-equal(props.get-static(--text), map-get($map2, --text), 'After update, get --text'); + @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'); - @include assert-equal(iro-props-clear(), null, 'Delete default tree'); + @include assert-equal(props.clear(), null, 'Delete default tree'); } @include it('Native assignment') { @@ -155,10 +159,10 @@ ); @include assert('Simple') { - @include iro-props-store($map); + @include props.store($map); @include output { - @include iro-props-assign; + @include props.assign; } @include expect { @@ -170,14 +174,14 @@ --buttons--default--text: #{map-get(map-get(map-get($map, --buttons), --default), --text)}; } - @include iro-props-clear; + @include props.clear; } @include assert('Filtered') { - @include iro-props-store($map); + @include props.store($map); @include output { - @include iro-props-assign($skip: --buttons); + @include props.assign($skip: --buttons); } @include expect { @@ -185,16 +189,16 @@ --text: #{map-get($map, --text)}; } - @include iro-props-clear; + @include props.clear; } @include assert('Namespaced') { - @include iro-props-namespace('ns') { - @include iro-props-store($map); + @include props.namespace('ns') { + @include props.store($map); } @include output { - @include iro-props-assign; + @include props.assign; } @include expect { @@ -206,7 +210,7 @@ --ns--buttons--default--text: #{map-get(map-get(map-get($map, --buttons), --default), --text)}; } - @include iro-props-clear; + @include props.clear; } } @@ -226,17 +230,17 @@ ) ); - @include assert-equal(iro-props-store($map), null, 'Save default tree'); + @include assert-equal(props.store($map), null, 'Save default tree'); - @include assert-equal(iro-props-get(--background), var(--background), 'Get --background'); - @include assert-equal(iro-props-get(--buttons --primary --text), var(--buttons--primary--text), 'Get --buttons --primary --text'); - @include assert-equal(iro-props-get(--buttons --secondary --text, $default: false), var(--buttons--secondary--text, false), 'Get --buttons --secondary --text with default'); - @include iro-props-namespace('buttons') { - @include assert-equal(iro-props-get(--primary --text), var(--buttons--primary--text), 'Get via namespace "buttons" --primary --text'); - @include assert-equal(iro-props-get(--secondary --text, $default: false), var(--buttons--secondary--text, false), 'Get via namespace "buttons" --secondary --text with default'); + @include assert-equal(props.get(--background), var(--background), 'Get --background'); + @include assert-equal(props.get(--buttons --primary --text), var(--buttons--primary--text), 'Get --buttons --primary --text'); + @include assert-equal(props.get(--buttons --secondary --text, $default: false), var(--buttons--secondary--text, false), 'Get --buttons --secondary --text with default'); + @include props.namespace('buttons') { + @include assert-equal(props.get(--primary --text), var(--buttons--primary--text), 'Get via namespace "buttons" --primary --text'); + @include assert-equal(props.get(--secondary --text, $default: false), var(--buttons--secondary--text, false), 'Get via namespace "buttons" --secondary --text with default'); } - @include assert-equal(iro-props-clear(), null, 'Delete default tree'); + @include assert-equal(props.clear(), null, 'Delete default tree'); } @include it('References') { @@ -255,25 +259,25 @@ --background: #eee, --buttons: ( --primary: ( - --background: iro-props-ref($key: --background) + --background: props.ref($key: --background) ), - --default: iro-props-ref($key: --buttons --primary) + --default: props.ref($key: --buttons --primary) ) ); - @include assert-equal(iro-props-store($map1), null, 'Save default tree'); - @include assert-equal(iro-props-store($map2, 'second'), null, 'Save "second" tree'); + @include assert-equal(props.store($map1), null, 'Save default tree'); + @include assert-equal(props.store($map2, 'second'), null, 'Save "second" tree'); - @include assert-equal(iro-props-get-static(--buttons --primary --background, 'second'), map-get($map1, --background), 'Get referenced value'); - @include assert-equal(iro-props-get(--buttons --primary --background, 'second'), var(--buttons--primary--background), 'Get referenced value, native'); + @include assert-equal(props.get-static(--buttons --primary --background, 'second'), map-get($map1, --background), 'Get referenced value'); + @include assert-equal(props.get(--buttons --primary --background, 'second'), var(--buttons--primary--background), 'Get referenced value, native'); - @include assert-equal(iro-props-get-static(--buttons --default, 'second'), map-get(map-get($map1, --buttons), --primary), 'Get referenced subtree, whole'); - @include assert-equal(iro-props-get-static(--buttons --default --background, 'second'), map-get(map-get(map-get($map1, --buttons), --primary), --background), 'Get referenced subtree, inner value'); - @include assert-equal(iro-props-get(--buttons --default --background, 'second'), var(--buttons--default--background), 'Get referenced subtree, native'); + @include assert-equal(props.get-static(--buttons --default, 'second'), map-get(map-get($map1, --buttons), --primary), 'Get referenced subtree, whole'); + @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'); + @include assert-equal(props.get(--buttons --default --background, 'second'), var(--buttons--default--background), 'Get referenced subtree, native'); @include assert('Native assignment') { @include output { - @include iro-props-assign('second'); + @include props.assign('second'); } @include expect { @@ -284,7 +288,7 @@ } } - @include assert-equal(iro-props-clear(), null, 'Delete default tree'); - @include assert-equal(iro-props-clear('second'), null, 'Delete "second" tree'); + @include assert-equal(props.clear(), null, 'Delete default tree'); + @include assert-equal(props.clear('second'), null, 'Delete "second" tree'); } } -- cgit v1.3.1