From 9f0a2a714b498edfbacc638fa79e06e3a8dc4d04 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 16 Sep 2017 10:42:24 +0200 Subject: Add basic search. --- .../mastodon_api/mastodon_api_controller_test.exs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 1b887cc24..1bef1a1fd 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -310,4 +310,26 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert [] = json_response(conn, 200) end) end + + test "search", %{conn: conn} do + user = insert(:user) + user_two = insert(:user, %{nickname: "shp@shitposter.club"}) + user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"}) + + {:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu"}) + {:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"}) + + conn = conn + |> get("/api/v1/search", %{"q" => "2hu"}) + + assert results = json_response(conn, 200) + + [account] = results["accounts"] + assert account["id"] == user_three.id + + assert results["hashtags"] == [] + + [status] = results["statuses"] + assert status["id"] == activity.id + end end -- cgit v1.2.3