theme-validate-keys.test.scss 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. @use '../theme';
  2. $origin-theme: (
  3. one: 1,
  4. two: '22',
  5. three: 3px,
  6. four: (
  7. x: 1,
  8. y: 2,
  9. ),
  10. );
  11. // Should validate when subset of keys are provided.
  12. @include theme.validate-theme(
  13. $origin-theme,
  14. (
  15. two: '22',
  16. three: 3px,
  17. )
  18. );
  19. // Should validate when theme configuration is empty.
  20. @include theme.validate-theme($origin-theme, ());
  21. // Should validate when nested theme keys are provided.
  22. @include theme.validate-theme(
  23. $origin-theme,
  24. (
  25. four: (
  26. x: 11,
  27. y: 22,
  28. ),
  29. )
  30. );
  31. // Should validate when custom property strings are provided.
  32. @include theme.validate-theme(
  33. $origin-theme,
  34. (
  35. one: var(--one),
  36. two: var(--two, 4px),
  37. )
  38. );
  39. // Should throw error when unsupported key (i.e., foobar) is provided.
  40. .test {
  41. @include theme.validate-theme(
  42. $origin-theme,
  43. (
  44. foobar: 66px,
  45. ),
  46. $test-only: true
  47. );
  48. }
  49. // Should throw error when custom properties are provided.
  50. .no-custom-props {
  51. @include theme.validate-theme(
  52. $origin-theme,
  53. (
  54. three: (
  55. varname: --three,
  56. fallback: teal,
  57. ),
  58. ),
  59. $test-only: true
  60. );
  61. }