JSONMinify.mjs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**
  2. * JSONMinify tests.
  3. *
  4. * @author Phillip Nordwall [Phillip.Nordwall@gmail.com]
  5. *
  6. * @copyright Crown Copyright 2018
  7. * @license Apache-2.0
  8. */
  9. import TestRegister from "../../TestRegister";
  10. TestRegister.addTests([
  11. {
  12. name: "JSON Minify: ''",
  13. input: "",
  14. expectedOutput: "",
  15. recipeConfig: [
  16. {
  17. op: "JSON Minify",
  18. args: [],
  19. },
  20. ],
  21. },
  22. {
  23. name: "JSON Minify: number",
  24. input: "42",
  25. expectedOutput: "42",
  26. recipeConfig: [
  27. {
  28. op: "JSON Minify",
  29. args: [],
  30. },
  31. ],
  32. },
  33. {
  34. name: "JSON Minify: number",
  35. input: "4.2",
  36. expectedOutput: "4.2",
  37. recipeConfig: [
  38. {
  39. op: "JSON Minify",
  40. args: [],
  41. },
  42. ],
  43. },
  44. {
  45. name: "JSON Minify: string",
  46. input: "\"string\"",
  47. expectedOutput: "\"string\"",
  48. recipeConfig: [
  49. {
  50. op: "JSON Minify",
  51. args: [],
  52. },
  53. ],
  54. },
  55. {
  56. name: "JSON Minify: boolean",
  57. input: "false",
  58. expectedOutput: "false",
  59. recipeConfig: [
  60. {
  61. op: "JSON Minify",
  62. args: [],
  63. },
  64. ],
  65. },
  66. {
  67. name: "JSON Minify: emptyList",
  68. input: "[\n \n \t]",
  69. expectedOutput: "[]",
  70. recipeConfig: [
  71. {
  72. op: "JSON Minify",
  73. args: [],
  74. },
  75. ],
  76. },
  77. {
  78. name: "JSON Minify: list",
  79. input: "[2,\n \t1]",
  80. expectedOutput: "[2,1]",
  81. recipeConfig: [
  82. {
  83. op: "JSON Minify",
  84. args: [],
  85. },
  86. ],
  87. },
  88. {
  89. name: "JSON Minify: object",
  90. input: "{\n \"second\": 2,\n \"first\": 3\n}",
  91. expectedOutput: "{\"second\":2,\"first\":3}",
  92. recipeConfig: [
  93. {
  94. op: "JSON Minify",
  95. args: [],
  96. },
  97. ],
  98. },
  99. {
  100. name: "JSON Minify: tab, nested",
  101. input: "[\n\t2,\n\t{\n\t\t\"second\": 2,\n\t\t\"first\": 3,\n\t\t\"beginning\": {\n\t\t\t\"j\": \"3\",\n\t\t\t\"i\": [\n\t\t\t\t2,\n\t\t\t\t3,\n\t\t\t\tfalse\n\t\t\t]\n\t\t}\n\t},\n\t1,\n\t2,\n\t3\n]",
  102. expectedOutput: "[2,{\"second\":2,\"first\":3,\"beginning\":{\"j\":\"3\",\"i\":[2,3,false]}},1,2,3]",
  103. recipeConfig: [
  104. {
  105. op: "JSON Minify",
  106. args: [],
  107. },
  108. ],
  109. },
  110. ]);