Code.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * Code tests.
  3. *
  4. * @author tlwr [toby@toby.codes]
  5. *
  6. * @copyright Crown Copyright 2017
  7. * @license Apache-2.0
  8. */
  9. import TestRegister from "../../TestRegister.js";
  10. TestRegister.addTests([
  11. {
  12. name: "To Camel case (dumb)",
  13. input: "hello world",
  14. expectedOutput: "helloWorld",
  15. recipeConfig: [
  16. {
  17. "op": "To Camel case",
  18. "args": [false]
  19. }
  20. ],
  21. },
  22. {
  23. name: "To Snake case (dumb)",
  24. input: "hello world",
  25. expectedOutput: "hello_world",
  26. recipeConfig: [
  27. {
  28. "op": "To Snake case",
  29. "args": [false]
  30. }
  31. ],
  32. },
  33. {
  34. name: "To Kebab case (dumb)",
  35. input: "hello world",
  36. expectedOutput: "hello-world",
  37. recipeConfig: [
  38. {
  39. "op": "To Kebab case",
  40. "args": [false]
  41. }
  42. ],
  43. },
  44. {
  45. name: "To Camel case (smart)",
  46. input: [
  47. "test='hello'",
  48. "echo $test",
  49. "a_camel_case_function",
  50. "$a_camel_case_variable;",
  51. "function function_name() {",
  52. " console.log('things inside quotes do not get broken');",
  53. " console.log(\"things inside quotes do not get broken\");",
  54. "}",
  55. ].join("\n"),
  56. expectedOutput: [
  57. "test='hello'",
  58. "echo $test",
  59. "aCamelCaseFunction",
  60. "$aCamelCaseVariable;",
  61. "function functionName() {",
  62. " console.log('things inside quotes do not get broken');",
  63. " console.log(\"things inside quotes do not get broken\");",
  64. "}",
  65. ].join("\n"),
  66. recipeConfig: [
  67. {
  68. "op": "To Camel case",
  69. "args": [true]
  70. }
  71. ],
  72. },
  73. {
  74. name: "To Snake case (smart)",
  75. input: [
  76. "test='hello'",
  77. "echo $test",
  78. "aSnakeCaseFunction",
  79. "$aSnakeCaseVariable;",
  80. "function functionName() {",
  81. " console.log('things inside quotes do not get broken');",
  82. " console.log(\"things inside quotes do not get broken\");",
  83. "}",
  84. ].join("\n"),
  85. expectedOutput: [
  86. "test='hello'",
  87. "echo $test",
  88. "a_snake_case_function",
  89. "$a_snake_case_variable;",
  90. "function function_name() {",
  91. " console.log('things inside quotes do not get broken');",
  92. " console.log(\"things inside quotes do not get broken\");",
  93. "}",
  94. ].join("\n"),
  95. recipeConfig: [
  96. {
  97. "op": "To Snake case",
  98. "args": [true]
  99. }
  100. ],
  101. },
  102. {
  103. name: "To Kebab case (smart)",
  104. input: [
  105. "test='hello'",
  106. "echo $test",
  107. "aKebabCaseFunction",
  108. "$aKebabCaseVariable;",
  109. "function functionName() {",
  110. " console.log('things inside quotes do not get broken');",
  111. " console.log(\"things inside quotes do not get broken\");",
  112. "}",
  113. ].join("\n"),
  114. expectedOutput: [
  115. "test='hello'",
  116. "echo $test",
  117. "a-kebab-case-function",
  118. "$a-kebab-case-variable;",
  119. "function function-name() {",
  120. " console.log('things inside quotes do not get broken');",
  121. " console.log(\"things inside quotes do not get broken\");",
  122. "}",
  123. ].join("\n"),
  124. recipeConfig: [
  125. {
  126. "op": "To Kebab case",
  127. "args": [true]
  128. }
  129. ],
  130. },
  131. ]);