tooty/tests/MastodonTest/HelperTest.elm

93 lines
4.5 KiB
Elm
Raw Normal View History

2017-04-27 14:34:27 +00:00
module MastodonTest.HelperTest exposing (..)
2017-04-25 14:27:15 +00:00
import Test exposing (..)
import Expect
2017-04-27 14:34:27 +00:00
import Mastodon.Helper
2017-04-25 14:27:15 +00:00
import Fixtures
all : Test
all =
describe "Notification test suite"
[ describe "Aggegate test"
[ test "Aggregate Notifications" <|
\() ->
Fixtures.notifications
2017-04-27 14:34:27 +00:00
|> Mastodon.Helper.aggregateNotifications
2017-04-25 14:27:15 +00:00
|> Expect.equal
[ { type_ = "mention"
, status = Just Fixtures.statusNicoToVjousse
, accounts = [ Fixtures.accountNico ]
, created_at = "2017-04-24T20:16:20.973Z"
}
, { type_ = "follow"
, status = Nothing
, accounts = [ Fixtures.accountNico, Fixtures.accountSkro ]
, created_at = "2017-04-24T20:13:47.431Z"
}
]
, test "Dedupes aggregated accounts" <|
\() ->
Fixtures.duplicateAccountNotifications
|> Mastodon.Helper.aggregateNotifications
|> List.map (.accounts >> List.length)
|> Expect.equal [ 1 ]
2017-04-25 14:27:15 +00:00
, test "Add follows notification to aggregate" <|
\() ->
Fixtures.notifications
2017-04-27 14:34:27 +00:00
|> Mastodon.Helper.aggregateNotifications
|> (Mastodon.Helper.addNotificationToAggregates Fixtures.notificationPloumFollowsVjousse)
2017-04-25 14:27:15 +00:00
|> Expect.equal
[ { type_ = "mention"
, status = Just Fixtures.statusNicoToVjousse
, accounts = [ Fixtures.accountNico ]
, created_at = "2017-04-24T20:16:20.973Z"
}
, { 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
2017-04-27 14:34:27 +00:00
|> Mastodon.Helper.aggregateNotifications
|> (Mastodon.Helper.addNotificationToAggregates Fixtures.notificationNicoMentionVjousse)
2017-04-25 14:27:15 +00:00
|> Expect.equal
[ { type_ = "mention"
, status = Just Fixtures.statusNicoToVjousse
, accounts = [ Fixtures.accountNico, Fixtures.accountNico ]
, created_at = "2017-04-24T20:16:20.973Z"
}
, { 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
2017-04-27 14:34:27 +00:00
|> Mastodon.Helper.aggregateNotifications
|> (Mastodon.Helper.addNotificationToAggregates Fixtures.notificationNicoMentionVjousseAgain)
2017-04-25 14:27:15 +00:00
|> Expect.equal
[ { type_ = "mention"
, status = Just Fixtures.statusNicoToVjousseAgain
, accounts = [ Fixtures.accountNico ]
, created_at = "2017-04-25T07:41:23.546Z"
}
, { type_ = "mention"
, status = Just Fixtures.statusNicoToVjousse
, accounts = [ Fixtures.accountNico ]
, created_at = "2017-04-24T20:16:20.973Z"
}
, { type_ = "follow"
, status = Nothing
, accounts = [ Fixtures.accountNico, Fixtures.accountSkro ]
, created_at = "2017-04-24T20:13:47.431Z"
}
]
]
]