logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

compiler_test.exs (2298B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Docs.Translator.CompilerTest do
  5. use ExUnit.Case, async: true
  6. alias Pleroma.Docs.Translator.Compiler
  7. @descriptions [
  8. %{
  9. key: "1",
  10. label: "1",
  11. description: "2",
  12. children: [
  13. %{
  14. key: "3",
  15. label: "3",
  16. description: "4"
  17. },
  18. %{
  19. key: "5",
  20. label: "5",
  21. description: "6"
  22. }
  23. ]
  24. },
  25. %{
  26. key: "7",
  27. label: "7",
  28. description: "8",
  29. children: [
  30. %{
  31. key: "9",
  32. description: "9",
  33. children: [
  34. %{
  35. key: "10",
  36. description: "10",
  37. children: [
  38. %{key: "11", description: "11"},
  39. %{description: "12"}
  40. ]
  41. }
  42. ]
  43. },
  44. %{
  45. label: "13"
  46. }
  47. ]
  48. },
  49. %{
  50. group: "14",
  51. label: "14"
  52. },
  53. %{
  54. group: "15",
  55. key: "15",
  56. label: "15"
  57. },
  58. %{
  59. group: {":subgroup", "16"},
  60. label: "16"
  61. }
  62. ]
  63. describe "extract_strings/1" do
  64. test "it extracts all labels and descriptions" do
  65. strings = Compiler.extract_strings(@descriptions)
  66. assert length(strings) == 16
  67. assert {["1"], "label", "1"} in strings
  68. assert {["1"], "description", "2"} in strings
  69. assert {["1", "3"], "label", "3"} in strings
  70. assert {["1", "3"], "description", "4"} in strings
  71. assert {["1", "5"], "label", "5"} in strings
  72. assert {["1", "5"], "description", "6"} in strings
  73. assert {["7"], "label", "7"} in strings
  74. assert {["7"], "description", "8"} in strings
  75. assert {["7", "9"], "description", "9"} in strings
  76. assert {["7", "9", "10"], "description", "10"} in strings
  77. assert {["7", "9", "10", "11"], "description", "11"} in strings
  78. assert {["7", "9", "10", nil], "description", "12"} in strings
  79. assert {["7", nil], "label", "13"} in strings
  80. assert {["14"], "label", "14"} in strings
  81. assert {["15-15"], "label", "15"} in strings
  82. assert {["16"], "label", "16"} in strings
  83. end
  84. end
  85. end