From 859449ed60bd7ce7476d0fedac958fd1a62c3a17 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 1 Apr 2022 16:41:00 +0530 Subject: [PATCH] Write test for map population --- scripts/postcss/test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/postcss/test.js b/scripts/postcss/test.js index 36ff9282..d07f07e4 100644 --- a/scripts/postcss/test.js +++ b/scripts/postcss/test.js @@ -96,6 +96,7 @@ module.exports.tests = function tests() { `; await run( inputCSS, outputCSS, { }, assert); }, + "multiple aliased-derived variable in single declaration is parsed correctly": async (assert) => { const inputCSS = ` :root { @@ -116,6 +117,23 @@ module.exports.tests = function tests() { } `; await run( inputCSS, outputCSS, { }, assert); + }, + + "compiledVariables map is populated": async (assert) => { + const compiledVariables = new Map(); + const inputCSS = ` + :root { + --icon-color: #fff; + } + div { + background: var(--icon-color--darker-20); + --my-alias: var(--icon-color--darker-20); + color: var(--my-alias--lighter-15); + }`; + await postcss([plugin({ derive, compiledVariables })]).process(inputCSS, { from: "/foo/bar/test.css", }); + const actualSet = compiledVariables.get("/foo/bar")["derived-variables"]; + const expectedSet = new Set(["icon-color--darker-20", "my-alias=icon-color--darker-20", "my-alias--lighter-15"]); + assert.deepEqual(actualSet, expectedSet); } }; };