Merge branch 'develop' of akkoma.dev:AkkomaGang/akkoma into develop
[akkoma] / test / pleroma / docs / translator / compiler_test.exs
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
5 defmodule Pleroma.Docs.Translator.CompilerTest do
6 use ExUnit.Case, async: true
7
8 alias Pleroma.Docs.Translator.Compiler
9
10 @descriptions [
11 %{
12 key: "1",
13 label: "1",
14 description: "2",
15 children: [
16 %{
17 key: "3",
18 label: "3",
19 description: "4"
20 },
21 %{
22 key: "5",
23 label: "5",
24 description: "6"
25 }
26 ]
27 },
28 %{
29 key: "7",
30 label: "7",
31 description: "8",
32 children: [
33 %{
34 key: "9",
35 description: "9",
36 children: [
37 %{
38 key: "10",
39 description: "10",
40 children: [
41 %{key: "11", description: "11"},
42 %{description: "12"}
43 ]
44 }
45 ]
46 },
47 %{
48 label: "13"
49 }
50 ]
51 },
52 %{
53 group: "14",
54 label: "14"
55 },
56 %{
57 group: "15",
58 key: "15",
59 label: "15"
60 },
61 %{
62 group: {":subgroup", "16"},
63 label: "16"
64 }
65 ]
66
67 describe "extract_strings/1" do
68 test "it extracts all labels and descriptions" do
69 strings = Compiler.extract_strings(@descriptions)
70 assert length(strings) == 16
71
72 assert {["1"], "label", "1"} in strings
73 assert {["1"], "description", "2"} in strings
74 assert {["1", "3"], "label", "3"} in strings
75 assert {["1", "3"], "description", "4"} in strings
76 assert {["1", "5"], "label", "5"} in strings
77 assert {["1", "5"], "description", "6"} in strings
78 assert {["7"], "label", "7"} in strings
79 assert {["7"], "description", "8"} in strings
80 assert {["7", "9"], "description", "9"} in strings
81 assert {["7", "9", "10"], "description", "10"} in strings
82 assert {["7", "9", "10", "11"], "description", "11"} in strings
83 assert {["7", "9", "10", nil], "description", "12"} in strings
84 assert {["7", nil], "label", "13"} in strings
85 assert {["14"], "label", "14"} in strings
86 assert {["15-15"], "label", "15"} in strings
87 assert {["16"], "label", "16"} in strings
88 end
89 end
90 end