@@ -23,76 +23,77 @@ defmodule GroupherServer.Test.CMS.Search do
2323
2424 describe "[cms search post]" do
2525 test "search post by full title should valid paged posts" do
26- { :ok , searched } = CMS . search_items ( :post , % { title: "react" } )
26+ { :ok , searched } = CMS . search_articles ( :post , % { title: "react" } )
2727
2828 assert searched |> is_valid_pagination? ( :raw )
2929 assert searched . total_count == 1
3030 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "react"
3131 end
3232
3333 test "search post blur title should return valid communities" do
34- { :ok , searched } = CMS . search_items ( :post , % { title: "reac" } )
34+ { :ok , searched } = CMS . search_articles ( :post , % { title: "reac" } )
3535 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "react"
3636
37- { :ok , searched } = CMS . search_items ( :post , % { title: "rea" } )
37+ { :ok , searched } = CMS . search_articles ( :post , % { title: "rea" } )
3838 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "react"
3939
40- { :ok , searched } = CMS . search_items ( :post , % { title: "eac" } )
40+ { :ok , searched } = CMS . search_articles ( :post , % { title: "eac" } )
4141 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "react"
4242
43- { :ok , searched } = CMS . search_items ( :post , % { title: "每日" } )
43+ { :ok , searched } = CMS . search_articles ( :post , % { title: "每日" } )
4444 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "每日妹子"
4545
46- { :ok , searched } = CMS . search_items ( :post , % { title: "javasc" } )
46+ { :ok , searched } = CMS . search_articles ( :post , % { title: "javasc" } )
4747 assert searched . total_count == 1
4848 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "javascript"
4949
50- { :ok , searched } = CMS . search_items ( :post , % { title: "java" } )
50+ { :ok , searched } = CMS . search_articles ( :post , % { title: "java" } )
5151 assert searched . total_count == 2
5252 assert searched . entries |> Enum . any? ( & ( & 1 . title == "java" ) )
5353 assert searched . entries |> Enum . any? ( & ( & 1 . title == "javascript" ) )
5454 end
5555
5656 test "search non exsit community should get empty pagi data" do
57- { :ok , searched } = CMS . search_items ( :community , % { title: "non-exsit" } )
57+ { :ok , searched } = CMS . search_communities ( "non-exsit" )
5858 assert searched |> is_valid_pagination? ( :raw , :empty )
5959 end
6060 end
6161
6262 describe "[cms search community]" do
6363 test "search community by full title should valid paged communities" do
64- { :ok , searched } = CMS . search_items ( :community , % { title: "react" } )
64+ { :ok , searched } = CMS . search_communities ( "react" )
6565
6666 assert searched |> is_valid_pagination? ( :raw )
6767 assert searched . total_count == 1
6868 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "react"
6969 end
7070
71+ @ tag :wip2
7172 test "search community blur title should return valid communities" do
72- { :ok , searched } = CMS . search_items ( :community , % { title: "reac" } )
73+ { :ok , searched } = CMS . search_communities ( "reac" )
7374 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "react"
7475
75- { :ok , searched } = CMS . search_items ( :community , % { title: "rea" } )
76+ { :ok , searched } = CMS . search_communities ( "rea" )
7677 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "react"
7778
78- { :ok , searched } = CMS . search_items ( :community , % { title: "eac" } )
79+ { :ok , searched } = CMS . search_communities ( "eac" )
7980 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "react"
8081
81- { :ok , searched } = CMS . search_items ( :community , % { title: "每日" } )
82+ { :ok , searched } = CMS . search_communities ( "每日" )
8283 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "每日妹子"
8384
84- { :ok , searched } = CMS . search_items ( :community , % { title: "javasc" } )
85+ { :ok , searched } = CMS . search_communities ( "javasc" )
8586 assert searched . total_count == 1
8687 assert searched . entries |> Enum . at ( 0 ) |> Map . get ( :title ) == "javascript"
8788
88- { :ok , searched } = CMS . search_items ( :community , % { title: "java" } )
89+ { :ok , searched } = CMS . search_communities ( "java" )
8990 assert searched . total_count == 2
9091 assert searched . entries |> Enum . any? ( & ( & 1 . title == "java" ) )
9192 assert searched . entries |> Enum . any? ( & ( & 1 . title == "javascript" ) )
9293 end
9394
9495 test "search non exsit community should get empty pagi data" do
95- { :ok , searched } = CMS . search_items ( :community , % { title: "non-exsit" } )
96+ { :ok , searched } = CMS . search_communities ( "non-exsit" )
9697 assert searched |> is_valid_pagination? ( :raw , :empty )
9798 end
9899 end
0 commit comments