transform.test.js 1014 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const { testTransform } = require('../test-helper');
  2. const transform = require('./transform');
  3. const input = `
  4. <template>
  5. <div class="widget">
  6. Hello {{name}}
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. name: {
  13. type: String,
  14. required: true
  15. },
  16. location: {
  17. type: String,
  18. required: false
  19. },
  20. age: {
  21. type: String
  22. }
  23. },
  24. computed: {
  25. hasName() {
  26. return !!this.name;
  27. }
  28. }
  29. };
  30. </script>
  31. <style>
  32. .widget {
  33. color: red;
  34. }
  35. </style>
  36. `;
  37. const output = `
  38. <template>
  39. <div class="widget">
  40. Hello {{name}}
  41. </div>
  42. </template>
  43. <script>
  44. export default {
  45. props: {
  46. name: {
  47. type: String,
  48. required: true
  49. },
  50. location: {
  51. type: String,
  52. required: true
  53. },
  54. age: {
  55. type: String,
  56. required: true
  57. }
  58. },
  59. computed: {
  60. hasName() {
  61. return !!this.name;
  62. }
  63. }
  64. };
  65. </script>
  66. <style>
  67. .widget {
  68. color: red;
  69. }
  70. </style>
  71. `;
  72. testTransform(transform, 'Widget.vue', input, output);