69f0cfdc54
* Get @mention in model * Add autocomplete logic * Get accounts to autocomplete from the server * Add autocomplete css * Check if we should show menu on account search * Add keyboard events * Update status with completed username * Trigger autocomplete when getting accounts back * Highlight choices on hover * Put focus on textarea after updating it * Fix clear draft * Hit the server only on non empty query * Lazzzzzzzzzzzzzzzzyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy * Add missing lazy * Add keyboard subscriptions * Add images and display name * Better menu visibility handling * Add lazy to notifications * Js formatting. * Improve styles. * Add unique keys to costly lists. * Fix tests. * Coding style nits. * Use the encodeUrl helper in ApiUrl. * Nanonit. * Improve autocomplete box styling. * CamelCase draft record * Move all autocomplete stuff to Draft * Send status to ports with the reply prefix. * Clear draft after posting a status. * Move ports setStatus call to a dedicated Command helper. * Naming. * Fix navigation with arrow keys in textarea * Always autoselect the first item of the menu
126 lines
6.6 KiB
Elm
126 lines
6.6 KiB
Elm
module MastodonTest.HelperTest exposing (..)
|
|
|
|
import Test exposing (..)
|
|
import Expect
|
|
import Mastodon.Helper exposing (..)
|
|
import Fixtures
|
|
|
|
|
|
all : Test
|
|
all =
|
|
describe "Mastodon.Helper tests"
|
|
[ describe "Reply tests"
|
|
[ test "Simple reply" <|
|
|
\() ->
|
|
Fixtures.statusNicoToVjousse
|
|
|> getReplyPrefix Fixtures.accountVjousse
|
|
|> Expect.equal "@n1k0 "
|
|
, test "Keeping replying to a previous post mentioning a user" <|
|
|
\() ->
|
|
Fixtures.statusNicoToVjousse
|
|
|> getReplyPrefix Fixtures.accountNico
|
|
|> Expect.equal "@vjousse "
|
|
, test "Replying to original poster and reblogger" <|
|
|
\() ->
|
|
Fixtures.statusReblogged
|
|
|> getReplyPrefix Fixtures.accountNico
|
|
|> Expect.equal "@ploum @vjousse "
|
|
, test "Exclude replier from generated reply prefix" <|
|
|
\() ->
|
|
Fixtures.statusNicoToVjousse
|
|
|> getReplyPrefix Fixtures.accountNico
|
|
|> Expect.equal "@vjousse "
|
|
]
|
|
, describe "Notification test suite"
|
|
[ describe "Aggegate test"
|
|
[ test "Aggregate Notifications" <|
|
|
\() ->
|
|
Fixtures.notifications
|
|
|> aggregateNotifications
|
|
|> Expect.equal
|
|
[ { id = .id Fixtures.notificationNicoMentionVjousse
|
|
, type_ = "mention"
|
|
, status = Just Fixtures.statusNicoToVjousse
|
|
, accounts = [ Fixtures.accountNico ]
|
|
, created_at = "2017-04-24T20:16:20.973Z"
|
|
}
|
|
, { id = .id Fixtures.notificationNicoFollowsVjousse
|
|
, type_ = "follow"
|
|
, status = Nothing
|
|
, accounts = [ Fixtures.accountNico, Fixtures.accountSkro ]
|
|
, created_at = "2017-04-24T20:13:47.431Z"
|
|
}
|
|
]
|
|
, test "Dedupes aggregated accounts" <|
|
|
\() ->
|
|
Fixtures.duplicateAccountNotifications
|
|
|> aggregateNotifications
|
|
|> List.map (.accounts >> List.length)
|
|
|> Expect.equal [ 1 ]
|
|
, test "Add follows notification to aggregate" <|
|
|
\() ->
|
|
Fixtures.notifications
|
|
|> aggregateNotifications
|
|
|> (addNotificationToAggregates Fixtures.notificationPloumFollowsVjousse)
|
|
|> Expect.equal
|
|
[ { id = .id Fixtures.notificationNicoMentionVjousse
|
|
, type_ = "mention"
|
|
, status = Just Fixtures.statusNicoToVjousse
|
|
, accounts = [ Fixtures.accountNico ]
|
|
, created_at = "2017-04-24T20:16:20.973Z"
|
|
}
|
|
, { id = .id Fixtures.notificationNicoFollowsVjousse
|
|
, type_ = "follow"
|
|
, status = Nothing
|
|
, accounts = [ Fixtures.accountPloum, Fixtures.accountNico, Fixtures.accountSkro ]
|
|
, created_at = "2017-04-24T20:13:47.431Z"
|
|
}
|
|
]
|
|
, test "Add mention notification to aggregate" <|
|
|
\() ->
|
|
Fixtures.notifications
|
|
|> aggregateNotifications
|
|
|> (addNotificationToAggregates Fixtures.notificationNicoMentionVjousse)
|
|
|> Expect.equal
|
|
[ { id = .id Fixtures.notificationNicoMentionVjousse
|
|
, type_ = "mention"
|
|
, status = Just Fixtures.statusNicoToVjousse
|
|
, accounts = [ Fixtures.accountNico, Fixtures.accountNico ]
|
|
, created_at = "2017-04-24T20:16:20.973Z"
|
|
}
|
|
, { id = .id Fixtures.notificationNicoFollowsVjousse
|
|
, type_ = "follow"
|
|
, status = Nothing
|
|
, accounts = [ Fixtures.accountNico, Fixtures.accountSkro ]
|
|
, created_at = "2017-04-24T20:13:47.431Z"
|
|
}
|
|
]
|
|
, test "Add new mention notification to aggregate" <|
|
|
\() ->
|
|
Fixtures.notifications
|
|
|> aggregateNotifications
|
|
|> (addNotificationToAggregates Fixtures.notificationNicoMentionVjousseAgain)
|
|
|> Expect.equal
|
|
[ { id = .id Fixtures.notificationNicoMentionVjousseAgain
|
|
, type_ = "mention"
|
|
, status = Just Fixtures.statusNicoToVjousseAgain
|
|
, accounts = [ Fixtures.accountNico ]
|
|
, created_at = "2017-04-25T07:41:23.546Z"
|
|
}
|
|
, { id = .id Fixtures.notificationNicoMentionVjousse
|
|
, type_ = "mention"
|
|
, status = Just Fixtures.statusNicoToVjousse
|
|
, accounts = [ Fixtures.accountNico ]
|
|
, created_at = "2017-04-24T20:16:20.973Z"
|
|
}
|
|
, { id = .id Fixtures.notificationNicoFollowsVjousse
|
|
, type_ = "follow"
|
|
, status = Nothing
|
|
, accounts = [ Fixtures.accountNico, Fixtures.accountSkro ]
|
|
, created_at = "2017-04-24T20:13:47.431Z"
|
|
}
|
|
]
|
|
]
|
|
]
|
|
]
|