0.2.80
This commit is contained in:
@@ -55,3 +55,29 @@ func TestUpdatePreferenceNeverSuppressesMandatoryUpdate(t *testing.T) {
|
||||
t.Fatalf("optional update was not suppressed: %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
// A clear-all press aimed at the alerts on screen must never reach past them. The one case
|
||||
// that can differ is a kind the viewer's own preferences have withdrawn: it is still a row
|
||||
// in the table, it is not in their list, and clearing it would be this shortcut deciding
|
||||
// something the viewer never saw.
|
||||
func TestClearableNotificationIDsHonourPreferences(t *testing.T) {
|
||||
notifications := []store.UserNotification{
|
||||
{ID: 1, Kind: "show-return"},
|
||||
{ID: 2, Kind: watchTimeWeeklyKind},
|
||||
{ID: 3, Kind: "library-added"},
|
||||
}
|
||||
prefs := store.DefaultNotificationPreferences()
|
||||
prefs.WatchTimeDigest = false
|
||||
ids := clearableNotificationIDs(notifications, prefs)
|
||||
if len(ids) != 2 || ids[0] != 1 || ids[1] != 3 {
|
||||
t.Fatalf("expected the two visible rows, got %v", ids)
|
||||
}
|
||||
|
||||
prefs.Enabled = false
|
||||
if ids := clearableNotificationIDs(notifications, prefs); len(ids) != 0 {
|
||||
t.Fatalf("notifications switched off should clear nothing, got %v", ids)
|
||||
}
|
||||
if ids := clearableNotificationIDs(nil, store.DefaultNotificationPreferences()); len(ids) != 0 {
|
||||
t.Fatalf("an empty list should clear nothing, got %v", ids)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user