cssVars.spec.ts.snap 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. // Vitest Snapshot v1
  2. exports[`CSS vars injection > codegen > <script> w/ default export 1`] = `
  3. "const __default__ = { setup() {} }
  4. import { useCssVars as _useCssVars } from 'vue'
  5. const __injectCSSVars__ = () => {
  6. _useCssVars((_vm, _setup) => ({
  7. \\"xxxxxxxx-color\\": (_vm.color)
  8. }))}
  9. const __setup__ = __default__.setup
  10. __default__.setup = __setup__
  11. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  12. : __injectCSSVars__
  13. export default __default__"
  14. `;
  15. exports[`CSS vars injection > codegen > <script> w/ default export in strings/comments 1`] = `
  16. "
  17. // export default {}
  18. const __default__ = {}
  19. import { useCssVars as _useCssVars } from 'vue'
  20. const __injectCSSVars__ = () => {
  21. _useCssVars((_vm, _setup) => ({
  22. \\"xxxxxxxx-color\\": (_vm.color)
  23. }))}
  24. const __setup__ = __default__.setup
  25. __default__.setup = __setup__
  26. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  27. : __injectCSSVars__
  28. export default __default__"
  29. `;
  30. exports[`CSS vars injection > codegen > <script> w/ no default export 1`] = `
  31. "const a = 1
  32. const __default__ = {}
  33. import { useCssVars as _useCssVars } from 'vue'
  34. const __injectCSSVars__ = () => {
  35. _useCssVars((_vm, _setup) => ({
  36. \\"xxxxxxxx-color\\": (_vm.color)
  37. }))}
  38. const __setup__ = __default__.setup
  39. __default__.setup = __setup__
  40. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  41. : __injectCSSVars__
  42. export default __default__"
  43. `;
  44. exports[`CSS vars injection > codegen > should ignore comments 1`] = `
  45. "import { useCssVars as _useCssVars } from 'vue'
  46. export default {
  47. setup(__props) {
  48. _useCssVars((_vm, _setup) => ({
  49. \\"xxxxxxxx-width\\": (_setup.width)
  50. }))
  51. const color = 'red';const width = 100
  52. return { color, width }
  53. }
  54. }"
  55. `;
  56. exports[`CSS vars injection > codegen > should work with w/ complex expression 1`] = `
  57. "import { useCssVars as _useCssVars } from 'vue'
  58. export default {
  59. setup(__props) {
  60. _useCssVars((_vm, _setup) => ({
  61. \\"xxxxxxxx-foo\\": (_setup.foo),
  62. \\"xxxxxxxx-foo____px_\\": (_setup.foo + 'px'),
  63. \\"xxxxxxxx-_a___b____2____px_\\": ((_setup.a + _setup.b) / 2 + 'px'),
  64. \\"xxxxxxxx-__a___b______2___a_\\": (((_setup.a + _setup.b)) / (2 * _setup.a))
  65. }))
  66. let a = 100
  67. let b = 200
  68. let foo = 300
  69. return { a, b, foo }
  70. }
  71. }"
  72. `;
  73. exports[`CSS vars injection > codegen > w/ <script setup> 1`] = `
  74. "import { useCssVars as _useCssVars } from 'vue'
  75. export default {
  76. setup(__props) {
  77. _useCssVars((_vm, _setup) => ({
  78. \\"xxxxxxxx-color\\": (_setup.color)
  79. }))
  80. const color = 'red'
  81. return { color }
  82. }
  83. }"
  84. `;
  85. exports[`CSS vars injection > codegen > w/ <script setup> using the same var multiple times 1`] = `
  86. "import { useCssVars as _useCssVars } from 'vue'
  87. export default {
  88. setup(__props) {
  89. _useCssVars((_vm, _setup) => ({
  90. \\"xxxxxxxx-color\\": (_setup.color)
  91. }))
  92. const color = 'red'
  93. return { color }
  94. }
  95. }"
  96. `;
  97. exports[`CSS vars injection > generating correct code for nested paths 1`] = `
  98. "const a = 1
  99. const __default__ = {}
  100. import { useCssVars as _useCssVars } from 'vue'
  101. const __injectCSSVars__ = () => {
  102. _useCssVars((_vm, _setup) => ({
  103. \\"xxxxxxxx-color\\": (_vm.color),
  104. \\"xxxxxxxx-font_size\\": (_vm.font.size)
  105. }))}
  106. const __setup__ = __default__.setup
  107. __default__.setup = __setup__
  108. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  109. : __injectCSSVars__
  110. export default __default__"
  111. `;
  112. exports[`CSS vars injection > w/ <script setup> binding analysis 1`] = `
  113. "import { useCssVars as _useCssVars } from 'vue'
  114. import { ref } from 'vue'
  115. export default {
  116. props: {
  117. foo: String
  118. },
  119. setup(__props) {
  120. _useCssVars((_vm, _setup) => ({
  121. \\"xxxxxxxx-color\\": (_setup.color),
  122. \\"xxxxxxxx-size\\": (_setup.size),
  123. \\"xxxxxxxx-foo\\": (_vm.foo)
  124. }))
  125. const color = 'red'
  126. const size = ref('10px')
  127. return { color, size, ref }
  128. }
  129. }"
  130. `;
  131. exports[`CSS vars injection > w/ normal <script> binding analysis 1`] = `
  132. "
  133. const __default__ = {
  134. setup() {
  135. return {
  136. size: ref('100px')
  137. }
  138. }
  139. }
  140. import { useCssVars as _useCssVars } from 'vue'
  141. const __injectCSSVars__ = () => {
  142. _useCssVars((_vm, _setup) => ({
  143. \\"xxxxxxxx-size\\": (_vm.size)
  144. }))}
  145. const __setup__ = __default__.setup
  146. __default__.setup = __setup__
  147. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  148. : __injectCSSVars__
  149. export default __default__"
  150. `;