Skip to content

Commit a1b37f9

Browse files
gwyneplainejesstelford
authored andcommitted
Add SASS unit test framework with sass-true
1 parent 8eac426 commit a1b37f9

File tree

4 files changed

+154
-1
lines changed

4 files changed

+154
-1
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"eslint": "^8.3.0",
7272
"execa": "^5.0.0",
7373
"jest": "^27.5.1",
74+
"jest-environment-node-single-context": "^27.3.0",
7475
"jest-preset-stylelint": "^5.0.3",
7576
"jest-watch-typeahead": "^1.0.0",
7677
"npm-run-all": "^4.1.5",
@@ -79,6 +80,7 @@
7980
"prettier": "^2.5.0",
8081
"rollup": "^3.12.0",
8182
"rollup-plugin-node-externals": "^5.1.0",
83+
"sass-true": "^7.0.0",
8284
"size-limit": "^5.0.3",
8385
"stylelint": "^14.15.0",
8486
"ts-node": "^10.7.0",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @jest-environment jest-environment-node-single-context
3+
*/
4+
const path = require('path');
5+
const fs = require('fs');
6+
7+
const sassTrue = require('sass-true');
8+
9+
sassTrue.runSass(
10+
{describe, it},
11+
'./src/styles/shared/test/_responsive-props.test.scss',
12+
);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@use 'true' as *;
2+
@import '../../common';
3+
4+
@include describe('@include responsive-props()') {
5+
@include it('Outputs the correct media query expressions') {
6+
@include assert {
7+
@include output {
8+
@include responsive-props('box', 'padding', 'padding-top');
9+
}
10+
11+
// stylelint-disable -- This is the generated output, it's not meant to be
12+
// formatted
13+
@include expect {
14+
--pc-box-padding-xs: initial;
15+
--pc-box-padding-sm: initial;
16+
--pc-box-padding-md: initial;
17+
--pc-box-padding-lg: initial;
18+
--pc-box-padding-xl: initial;
19+
20+
padding-top: var(--pc-box-padding-xs, initial);
21+
22+
@media (min-width: 30.625em) {
23+
padding-top: var(
24+
--pc-box-padding-sm,
25+
var(--pc-box-padding-xs, initial)
26+
);
27+
}
28+
@media (min-width: 48em) {
29+
padding-top: var(
30+
--pc-box-padding-md,
31+
var(--pc-box-padding-sm, var(--pc-box-padding-xs, initial))
32+
);
33+
}
34+
@media (min-width: 65em) {
35+
padding-top: var(
36+
--pc-box-padding-lg,
37+
var(
38+
--pc-box-padding-md,
39+
var(--pc-box-padding-sm, var(--pc-box-padding-xs, initial))
40+
)
41+
);
42+
}
43+
@media (min-width: 90em) {
44+
padding-top: var(
45+
--pc-box-padding-xl,
46+
var(
47+
--pc-box-padding-lg,
48+
var(
49+
--pc-box-padding-md,
50+
var(--pc-box-padding-sm, var(--pc-box-padding-xs, initial))
51+
)
52+
)
53+
);
54+
}
55+
}
56+
// stylelint-enable
57+
}
58+
}
59+
}

yarn.lock

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,13 @@
17561756
dependencies:
17571757
"@sinclair/typebox" "^0.23.3"
17581758

1759+
"@jest/schemas@^29.6.3":
1760+
version "29.6.3"
1761+
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03"
1762+
integrity sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==
1763+
dependencies:
1764+
"@sinclair/typebox" "^0.27.8"
1765+
17591766
"@jest/source-map@^27.5.1":
17601767
version "27.5.1"
17611768
resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-27.5.1.tgz#6608391e465add4205eae073b55e7f279e04e8cf"
@@ -2645,6 +2652,11 @@
26452652
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.23.4.tgz#6ff93fd2585ce44f7481c9ff6af610fbb5de98a4"
26462653
integrity sha512-0/WqSvpVbCBAV1yPeko7eAczKbs78dNVAaX14quVlwOb2wxfKuXCx91h4NrEfkYK9zEnyVSW4JVI/trP3iS+Qg==
26472654

2655+
"@sinclair/typebox@^0.27.8":
2656+
version "0.27.8"
2657+
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"
2658+
integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==
2659+
26482660
"@sindresorhus/is@^4.0.0":
26492661
version "4.6.0"
26502662
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f"
@@ -3674,6 +3686,11 @@
36743686
dependencies:
36753687
"@types/node" "*"
36763688

3689+
"@types/css@^0.0.33":
3690+
version "0.0.33"
3691+
resolved "https://registry.yarnpkg.com/@types/css/-/css-0.0.33.tgz#d0b49c4090c09c8e5dc01364560627e5ebb770f2"
3692+
integrity sha512-qjeDgh86R0LIeEM588q65yatc8Yyo/VvSIYFqq8JOIHDolhGNX0rz7k/OuxqDpnpqlefoHj8X4Ai/6hT9IWtKQ==
3693+
36773694
"@types/debug@^4.0.0":
36783695
version "4.1.7"
36793696
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.7.tgz#7cc0ea761509124709b8b2d1090d8f6c17aadb82"
@@ -7672,6 +7689,15 @@ css-what@^6.0.1:
76727689
resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4"
76737690
integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==
76747691

7692+
css@^3.0.0:
7693+
version "3.0.0"
7694+
resolved "https://registry.yarnpkg.com/css/-/css-3.0.0.tgz#4447a4d58fdd03367c516ca9f64ae365cee4aa5d"
7695+
integrity sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ==
7696+
dependencies:
7697+
inherits "^2.0.4"
7698+
source-map "^0.6.1"
7699+
source-map-resolve "^0.6.0"
7700+
76757701
cssesc@^3.0.0:
76767702
version "3.0.0"
76777703
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee"
@@ -8151,6 +8177,11 @@ diff-sequences@^27.5.1:
81518177
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327"
81528178
integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==
81538179

8180+
diff-sequences@^29.6.3:
8181+
version "29.6.3"
8182+
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.6.3.tgz#4deaf894d11407c51efc8418012f9e70b84ea921"
8183+
integrity sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==
8184+
81548185
diff@^4.0.1:
81558186
version "4.0.2"
81568187
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
@@ -12577,6 +12608,16 @@ jest-diff@^27.5.1:
1257712608
jest-get-type "^27.5.1"
1257812609
pretty-format "^27.5.1"
1257912610

12611+
jest-diff@^29.3.1:
12612+
version "29.7.0"
12613+
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.7.0.tgz#017934a66ebb7ecf6f205e84699be10afd70458a"
12614+
integrity sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==
12615+
dependencies:
12616+
chalk "^4.0.0"
12617+
diff-sequences "^29.6.3"
12618+
jest-get-type "^29.6.3"
12619+
pretty-format "^29.7.0"
12620+
1258012621
jest-docblock@^27.5.1:
1258112622
version "27.5.1"
1258212623
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-27.5.1.tgz#14092f364a42c6108d42c33c8cf30e058e25f6c0"
@@ -12608,7 +12649,14 @@ jest-environment-jsdom@^27.5.1:
1260812649
jest-util "^27.5.1"
1260912650
jsdom "^16.6.0"
1261012651

12611-
jest-environment-node@^27.5.1:
12652+
jest-environment-node-single-context@^27.3.0:
12653+
version "27.3.0"
12654+
resolved "https://registry.yarnpkg.com/jest-environment-node-single-context/-/jest-environment-node-single-context-27.3.0.tgz#c520ec646b957782bbcc27da9512a96d42925924"
12655+
integrity sha512-28sQFZhG92C6Zr+Tue9sHL9n68a40ZnQmyiu0Ajh3c7yRauX1x2PB9LyUxuZ9imcBOYKEzMitnG69WsSsP9bNg==
12656+
dependencies:
12657+
jest-environment-node "^27.2.4"
12658+
12659+
jest-environment-node@^27.2.4, jest-environment-node@^27.5.1:
1261212660
version "27.5.1"
1261312661
resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-27.5.1.tgz#dedc2cfe52fab6b8f5714b4808aefa85357a365e"
1261412662
integrity sha512-Jt4ZUnxdOsTGwSRAfKEnE6BcwsSPNOijjwifq5sDFSA2kesnXTvNqKHYgM0hDq3549Uf/KzdXNYn4wMZJPlFLw==
@@ -12630,6 +12678,11 @@ jest-get-type@^27.5.1:
1263012678
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1"
1263112679
integrity sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==
1263212680

12681+
jest-get-type@^29.6.3:
12682+
version "29.6.3"
12683+
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.6.3.tgz#36f499fdcea197c1045a127319c0481723908fd1"
12684+
integrity sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==
12685+
1263312686
jest-haste-map@^27.5.1:
1263412687
version "27.5.1"
1263512688
resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-27.5.1.tgz#9fd8bd7e7b4fa502d9c6164c5640512b4e811e7f"
@@ -17298,6 +17351,15 @@ pretty-format@^28.0.2:
1729817351
ansi-styles "^5.0.0"
1729917352
react-is "^18.0.0"
1730017353

17354+
pretty-format@^29.7.0:
17355+
version "29.7.0"
17356+
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812"
17357+
integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==
17358+
dependencies:
17359+
"@jest/schemas" "^29.6.3"
17360+
ansi-styles "^5.0.0"
17361+
react-is "^18.0.0"
17362+
1730117363
pretty-hrtime@^1.0.3:
1730217364
version "1.0.3"
1730317365
resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1"
@@ -18724,6 +18786,16 @@ sass-loader@^12.4.0:
1872418786
klona "^2.0.4"
1872518787
neo-async "^2.6.2"
1872618788

18789+
sass-true@^7.0.0:
18790+
version "7.0.0"
18791+
resolved "https://registry.yarnpkg.com/sass-true/-/sass-true-7.0.0.tgz#eabbc92f29b2d602a57234ec0fe65050fb0df930"
18792+
integrity sha512-sRdXX7MrrYdg+lPRm+/vIr8wVvDrNtWj3ttOVyIMHZQ8vNoV67+YjZKTsY9+B4Ecee+/U3ryXKJLi1YcMEkaJQ==
18793+
dependencies:
18794+
"@types/css" "^0.0.33"
18795+
css "^3.0.0"
18796+
jest-diff "^29.3.1"
18797+
lodash "^4.17.21"
18798+
1872718799
sass@^1.49.9:
1872818800
version "1.51.0"
1872918801
resolved "https://registry.yarnpkg.com/sass/-/sass-1.51.0.tgz#25ea36cf819581fe1fe8329e8c3a4eaaf70d2845"
@@ -19317,6 +19389,14 @@ source-map-resolve@^0.5.0:
1931719389
source-map-url "^0.4.0"
1931819390
urix "^0.1.0"
1931919391

19392+
source-map-resolve@^0.6.0:
19393+
version "0.6.0"
19394+
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2"
19395+
integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w==
19396+
dependencies:
19397+
atob "^2.1.2"
19398+
decode-uri-component "^0.2.0"
19399+
1932019400
source-map-support@^0.5.16, source-map-support@^0.5.21, source-map-support@^0.5.6, source-map-support@~0.5.12, source-map-support@~0.5.20:
1932119401
version "0.5.21"
1932219402
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"

0 commit comments

Comments
 (0)