@@ -169,176 +169,87 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Image do
169
169
assert Utils . str_occurence ( converted , gallery_mini_image_class ) == length ( @ images )
170
170
end
171
171
172
- # @tag :wip
173
- # test "edit exsit block will not change id value" do
174
- # editor_json =
175
- # set_items(
176
- # "order_list",
177
- # [
178
- # %{
179
- # "checked" => true,
180
- # "hideLabel" => false,
181
- # "indent" => 0,
182
- # "label" => "label",
183
- # "labelType" => "default",
184
- # "prefixIndex" => "1.",
185
- # "text" =>
186
- # "一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。"
187
- # }
188
- # ],
189
- # "exsit"
190
- # )
191
-
192
- # {:ok, editor_string} = Jason.encode(editor_json)
193
- # {:ok, converted} = Parser.to_html(editor_string)
194
-
195
- # assert Utils.str_occurence(converted, "id=\"exsit\"") == 1
196
- # end
197
-
198
- # @tag :wip
199
- # test "basic checklist parse should work" do
200
- # editor_json =
201
- # set_items("checklist", [
202
- # %{
203
- # "checked" => true,
204
- # "hideLabel" => false,
205
- # "indent" => 0,
206
- # "label" => "label",
207
- # "labelType" => "default",
208
- # "text" =>
209
- # "一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。一个带着中文的很长的句子。"
210
- # },
211
- # %{
212
- # "checked" => false,
213
- # "hideLabel" => false,
214
- # "indent" => 0,
215
- # "label" => "label",
216
- # "labelType" => "default",
217
- # "text" => "list item"
218
- # },
219
- # %{
220
- # "checked" => false,
221
- # "hideLabel" => false,
222
- # "indent" => 1,
223
- # "label" => "green",
224
- # "labelType" => "green",
225
- # "text" => "list item"
226
- # },
227
- # %{
228
- # "checked" => false,
229
- # "hideLabel" => false,
230
- # "indent" => 1,
231
- # "label" => "red",
232
- # "labelType" => "red",
233
- # "text" => "list item"
234
- # }
235
- # ])
236
-
237
- # {:ok, editor_string} = Jason.encode(editor_json)
238
- # {:ok, converted} = Parser.to_html(editor_string)
239
-
240
- # checked_class = @class["checklist_checkbox_checked"]
241
- # assert Utils.str_occurence(converted, checked_class) == 1
242
- # end
172
+ @ tag :wip
173
+ test "edit exsit block will not change id value" do
174
+ editor_json =
175
+ set_items (
176
+ "gallery" ,
177
+ @ images
178
+ |> Enum . with_index ( )
179
+ |> Enum . map ( fn { src , index } ->
180
+ % {
181
+ "index" => index ,
182
+ "src" => src ,
183
+ "caption" => "this is a caption 1"
184
+ }
185
+ end ) ,
186
+ "exsit"
187
+ )
243
188
244
- # @tag :wip
245
- # test "checklist without label parse should work" do
246
- # editor_json =
247
- # set_items("checklist", [
248
- # %{
249
- # "checked" => true,
250
- # "hideLabel" => true,
251
- # "indent" => 0,
252
- # "label" => "label",
253
- # "labelType" => "default",
254
- # "text" => "list item"
255
- # },
256
- # %{
257
- # "checked" => false,
258
- # "hideLabel" => true,
259
- # "indent" => 0,
260
- # "label" => "label",
261
- # "labelType" => "default",
262
- # "text" => "list item"
263
- # }
264
- # ])
189
+ { :ok , editor_string } = Jason . encode ( editor_json )
190
+ { :ok , converted } = Parser . to_html ( editor_string )
265
191
266
- # {:ok, editor_string} = Jason.encode(editor_json)
267
- # {:ok, converted} = Parser.to_html(editor_string)
192
+ assert Utils . str_occurence ( converted , "id= \" exsit \" " ) == 1
193
+ end
268
194
269
- # label_class = @class["label"]
270
- # assert Utils.str_occurence(converted, label_class) == 0
271
- # end
195
+ @ tag :wip2
196
+ test "invalid mode parse should raise error message" do
197
+ editor_json = set_items ( "invalid-mode" , [ ] )
198
+ { :ok , editor_string } = Jason . encode ( editor_json )
199
+ { :error , err_msg } = Parser . to_html ( editor_string )
200
+
201
+ assert err_msg == [
202
+ % {
203
+ block: "image" ,
204
+ field: "mode" ,
205
+ message: "should be: single | jiugongge | gallery"
206
+ }
207
+ ]
208
+ end
272
209
273
- # @tag :wip
274
- # test "invalid list mode parse should raise error message" do
275
- # editor_json = set_items("invalid-mode", [])
276
- # {:ok, editor_string} = Jason.encode(editor_json)
277
- # {:error, err_msg} = Parser.to_html(editor_string)
210
+ @ tag :wip2
211
+ test "invalid data parse should raise error message" do
212
+ editor_json =
213
+ set_items ( "single" , [
214
+ % {
215
+ "index" => "invalid" ,
216
+ "src" => "src"
217
+ }
218
+ ] )
278
219
279
- # assert err_msg == [
280
- # %{
281
- # block: "list",
282
- # field: "mode",
283
- # message: "should be: checklist | order_list | unorder_list"
284
- # }
285
- # ]
286
- # end
220
+ { :ok , editor_string } = Jason . encode ( editor_json )
221
+ { :error , err_msg } = Parser . to_html ( editor_string )
222
+
223
+ assert err_msg == [
224
+ % {
225
+ block: "image(single)" ,
226
+ field: "index" ,
227
+ message: "should be: number" ,
228
+ value: "invalid"
229
+ }
230
+ ]
231
+ end
287
232
288
- # @tag :wip
289
- # test "invalidlist data parse should raise error message" do
233
+ # @tag :wip2
234
+ # test "invalidsrc parse should raise error message" do
290
235
# editor_json =
291
- # set_items("checklist ", [
236
+ # set_items("single ", [
292
237
# %{
293
- # "checked" => true,
294
- # "hideLabel" => "invalid",
295
- # "indent" => 5,
296
- # "label" => "label",
297
- # "labelType" => "default",
298
- # "text" => "list item"
238
+ # "index" => 0,
239
+ # "src" => "src"
299
240
# }
300
241
# ])
301
242
302
243
# {:ok, editor_string} = Jason.encode(editor_json)
303
244
# {:error, err_msg} = Parser.to_html(editor_string)
245
+ # IO.inspect(err_msg, label: "err_msg")
304
246
305
247
# assert err_msg == [
306
248
# %{
307
- # block: "list(checklist )",
308
- # field: "hideLabel ",
309
- # message: "should be:boolean ",
249
+ # block: "image(single )",
250
+ # field: "index ",
251
+ # message: "should be:number ",
310
252
# value: "invalid"
311
- # },
312
- # %{
313
- # block: "list(checklist)",
314
- # field: "indent",
315
- # message: "should be: 0 | 1 | 2 | 3"
316
- # }
317
- # ]
318
- # end
319
-
320
- # @tag :wip
321
- # test "invalid indent field should get error" do
322
- # editor_json =
323
- # set_items("checklist", [
324
- # %{
325
- # "checked" => true,
326
- # "hideLabel" => true,
327
- # "indent" => 10,
328
- # "label" => "label",
329
- # "labelType" => "default",
330
- # "text" => "list item"
331
- # }
332
- # ])
333
-
334
- # {:ok, editor_string} = Jason.encode(editor_json)
335
- # {:error, error} = Parser.to_html(editor_string)
336
-
337
- # assert error === [
338
- # %{
339
- # block: "list(checklist)",
340
- # field: "indent",
341
- # message: "should be: 0 | 1 | 2 | 3"
342
253
# }
343
254
# ]
344
255
# end