-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelper_test.go
More file actions
52 lines (48 loc) · 1.68 KB
/
Copy pathhelper_test.go
File metadata and controls
52 lines (48 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestMentionVisible(t *testing.T) {
base := time.Date(2026, 6, 1, 12, 0, 0, 0, time.UTC)
before := base.Add(-time.Hour)
after := base.Add(time.Hour)
tests := []struct {
name string
hss *time.Time
parent *time.Time
visible bool
}{
{"nil window is unrestricted", nil, &base, true},
{"nil window nil parent still unrestricted", nil, nil, true},
{"parent after window is visible", &before, &base, true},
{"parent equal to window is visible", &base, &base, true},
{"parent before window is hidden", &after, &base, false},
{"set window with nil parent is hidden", &before, nil, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.visible, mentionVisible(tt.hss, tt.parent))
})
}
}
func TestDedupedAccounts(t *testing.T) {
cases := []struct {
name string
sender string
mentions []string
want []string
}{
{name: "no mentions", sender: "alice", want: []string{"alice"}},
{name: "mentions exclude sender", sender: "alice", mentions: []string{"bob", "carol"}, want: []string{"alice", "bob", "carol"}},
{name: "sender appears in mentions", sender: "alice", mentions: []string{"alice", "bob"}, want: []string{"alice", "bob"}},
{name: "duplicate mentions", sender: "alice", mentions: []string{"bob", "bob", "carol"}, want: []string{"alice", "bob", "carol"}},
{name: "preserves mention order", sender: "alice", mentions: []string{"carol", "bob"}, want: []string{"alice", "carol", "bob"}},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.want, dedupedAccounts(tc.sender, tc.mentions))
})
}
}