Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit eba4441

Browse files
committed
refactor(editor-test): rm unsed class vars
1 parent 14ae758 commit eba4441

File tree

6 files changed

+23
-52
lines changed

6 files changed

+23
-52
lines changed

test/helper/converter/editor_to_html_test/header_test.exs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Header do
1010
@root_class Class.article()
1111
@class get_in(@root_class, ["header"])
1212

13-
@eyebrow_class @class["eyebrow_title"]
14-
@footer_class @class["footer_title"]
15-
1613
describe "[header block unit]" do
1714
defp set_data(data) do
1815
%{
@@ -80,8 +77,8 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Header do
8077
# header_class = @class["header"]
8178
assert Utils.str_occurence(converted, "id=") == 1
8279
# assert Utils.str_occurence(converted, header_class) == 1
83-
assert Utils.str_occurence(converted, @eyebrow_class) == 1
84-
assert Utils.str_occurence(converted, @footer_class) == 1
80+
assert Utils.str_occurence(converted, @class["eyebrow_title"]) == 1
81+
assert Utils.str_occurence(converted, @class["footer_title"]) == 1
8582
end
8683

8784
@tag :wip
@@ -113,8 +110,8 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Header do
113110
{:ok, editor_string} = Jason.encode(editor_json)
114111
{:ok, converted} = Parser.to_html(editor_string)
115112

116-
assert Utils.str_occurence(converted, @eyebrow_class) == 1
117-
assert Utils.str_occurence(converted, @footer_class) == 0
113+
assert Utils.str_occurence(converted, @class["eyebrow_title"]) == 1
114+
assert Utils.str_occurence(converted, @class["footer_title"]) == 0
118115

119116
editor_json =
120117
set_data(%{
@@ -126,8 +123,8 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Header do
126123
{:ok, editor_string} = Jason.encode(editor_json)
127124
{:ok, converted} = Parser.to_html(editor_string)
128125

129-
assert Utils.str_occurence(converted, @eyebrow_class) == 0
130-
assert Utils.str_occurence(converted, @footer_class) == 1
126+
assert Utils.str_occurence(converted, @class["eyebrow_title"]) == 0
127+
assert Utils.str_occurence(converted, @class["footer_title"]) == 1
131128
end
132129

133130
@tag :wip

test/helper/converter/editor_to_html_test/index_test.exs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,8 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML do
132132
{:ok, editor_string} = Jason.encode(editor_json)
133133
{:ok, converted} = Parser.to_html(editor_string)
134134

135-
viewer_class = @root_class["viewer"]
136-
137135
assert converted ==
138-
~s(<div class="#{viewer_class}"><p>evel script</p></div>)
136+
~s(<div class="#{@root_class["viewer"]}"><p>evel script</p></div>)
139137

140138
editor_json = %{
141139
"time" => 1_567_250_876_713,
@@ -153,10 +151,8 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML do
153151
{:ok, editor_string} = Jason.encode(editor_json)
154152
{:ok, converted} = Parser.to_html(editor_string)
155153

156-
viewer_class = @root_class["viewer"]
157-
158154
assert converted ==
159-
~s(<div class="#{viewer_class}"><p>Editor.js is an element &lt;script&gt;evel script&lt;/script&gt;</p></div>)
155+
~s(<div class="#{@root_class["viewer"]}"><p>Editor.js is an element &lt;script&gt;evel script&lt;/script&gt;</p></div>)
160156
end
161157
end
162158
end

test/helper/converter/editor_to_html_test/list_test.exs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.List do
6161
{:ok, editor_string} = Jason.encode(editor_json)
6262
{:ok, converted} = Parser.to_html(editor_string)
6363

64-
unorder_list_prefix_class = @class["unorder_list_prefix"]
65-
assert Utils.str_occurence(converted, unorder_list_prefix_class) == 3
64+
assert Utils.str_occurence(converted, @class["unorder_list_prefix"]) == 3
6665
end
6766

6867
@tag :wip
@@ -104,8 +103,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.List do
104103

105104
assert Utils.str_occurence(converted, "id=") == 1
106105

107-
order_list_prefix_class = @class["order_list_prefix"]
108-
assert Utils.str_occurence(converted, order_list_prefix_class) == 3
106+
assert Utils.str_occurence(converted, @class["order_list_prefix"]) == 3
109107
end
110108

111109
@tag :wip
@@ -176,8 +174,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.List do
176174
{:ok, editor_string} = Jason.encode(editor_json)
177175
{:ok, converted} = Parser.to_html(editor_string)
178176

179-
checked_class = @class["checklist_checkbox_checked"]
180-
assert Utils.str_occurence(converted, checked_class) == 1
177+
assert Utils.str_occurence(converted, @class["checklist_checkbox_checked"]) == 1
181178
end
182179

183180
@tag :wip
@@ -205,8 +202,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.List do
205202
{:ok, editor_string} = Jason.encode(editor_json)
206203
{:ok, converted} = Parser.to_html(editor_string)
207204

208-
label_class = @class["label"]
209-
assert Utils.str_occurence(converted, label_class) == 0
205+
assert Utils.str_occurence(converted, @class["label"]) == 0
210206
end
211207

212208
@tag :wip

test/helper/converter/editor_to_html_test/paragraph_test.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Paragraph do
2626
{:ok, editor_string} = Jason.encode(@editor_json)
2727
{:ok, converted} = Parser.to_html(editor_string)
2828

29-
viewer_class = @root_class["viewer"]
30-
assert converted == ~s(<div class="#{viewer_class}"><p>paragraph content</p></div>)
29+
assert converted == ~s(<div class="#{@root_class["viewer"]}"><p>paragraph content</p></div>)
3130
end
3231

3332
@editor_json %{

test/helper/converter/editor_to_html_test/quote_test.exs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Quote do
4949

5050
assert Utils.str_occurence(converted, "id=") == 1
5151

52-
short_wrapper_class = @class["short_wrapper"]
53-
caption_class = @class["caption"]
54-
55-
assert Utils.str_occurence(converted, short_wrapper_class) == 1
52+
assert Utils.str_occurence(converted, @class["short_wrapper"]) == 1
5653
assert Utils.str_occurence(converted, "</blockquote>") == 1
57-
assert Utils.str_occurence(converted, caption_class) == 0
54+
assert Utils.str_occurence(converted, @class["caption"]) == 0
5855
end
5956

6057
@tag :wip
@@ -63,42 +60,31 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Quote do
6360
{:ok, editor_string} = Jason.encode(editor_json)
6461
{:ok, converted} = Parser.to_html(editor_string)
6562

66-
long_wrapper_class = @class["long_wrapper"]
67-
caption_text_class = @class["caption_text"]
68-
69-
assert Utils.str_occurence(converted, long_wrapper_class) == 1
63+
assert Utils.str_occurence(converted, @class["long_wrapper"]) == 1
7064
assert Utils.str_occurence(converted, "</blockquote>") == 1
71-
assert Utils.str_occurence(converted, caption_text_class) == 1
65+
assert Utils.str_occurence(converted, @class["caption_text"]) == 1
7266
end
7367

7468
@tag :wip
7569
test "long quote without caption parse should work" do
7670
editor_json = set_data("long", "long quote")
7771
{:ok, editor_string} = Jason.encode(editor_json)
78-
7972
{:ok, converted} = Parser.to_html(editor_string)
8073

81-
long_wrapper_class = @class["long_wrapper"]
82-
caption_text_class = @class["caption_text"]
83-
84-
assert Utils.str_occurence(converted, long_wrapper_class) == 1
74+
assert Utils.str_occurence(converted, @class["long_wrapper"]) == 1
8575
assert Utils.str_occurence(converted, "</blockquote>") == 1
86-
assert Utils.str_occurence(converted, caption_text_class) == 0
76+
assert Utils.str_occurence(converted, @class["caption_text"]) == 0
8777
end
8878

8979
@tag :wip
9080
test "long quote without empty caption parse should work" do
9181
editor_json = set_data("long", "long quote", "")
9282
{:ok, editor_string} = Jason.encode(editor_json)
93-
9483
{:ok, converted} = Parser.to_html(editor_string)
9584

96-
long_wrapper_class = @class["long_wrapper"]
97-
caption_text_class = @class["caption_text"]
98-
99-
assert Utils.str_occurence(converted, long_wrapper_class) == 1
85+
assert Utils.str_occurence(converted, @class["long_wrapper"]) == 1
10086
assert Utils.str_occurence(converted, "</blockquote>") == 1
101-
assert Utils.str_occurence(converted, caption_text_class) == 0
87+
assert Utils.str_occurence(converted, @class["caption_text"]) == 0
10288
end
10389

10490
@tag :wip

test/helper/converter/editor_to_html_test/table_test.exs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,8 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Table do
100100

101101
assert Utils.str_occurence(converted, "id=") == 1
102102

103-
th_header_class = @class["th_header"]
104-
td_stripe_class = @class["td_stripe"]
105-
106-
assert Utils.str_occurence(converted, th_header_class) == 4
107-
assert Utils.str_occurence(converted, td_stripe_class) == 3
103+
assert Utils.str_occurence(converted, @class["th_header"]) == 4
104+
assert Utils.str_occurence(converted, @class["td_stripe"]) == 3
108105
end
109106

110107
@tag :wip

0 commit comments

Comments
 (0)