mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-12-09 12:21:04 +01:00
sdk: return start and end on references for replacement.
This commit is contained in:
@@ -19,28 +19,36 @@ func TestParseReferences(t *testing.T) {
|
||||
|
||||
expected := []Reference{
|
||||
{
|
||||
Text: "#[0]",
|
||||
Text: "#[0]",
|
||||
Start: 6,
|
||||
End: 10,
|
||||
Profile: &nostr.ProfilePointer{
|
||||
PublicKey: "c9d556c6d3978d112d30616d0d20aaa81410e3653911dd67787b5aaf9b36ade8",
|
||||
Relays: []string{"wss://nostr.com"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Text: "#[2]",
|
||||
Text: "#[2]",
|
||||
Start: 26,
|
||||
End: 30,
|
||||
Event: &nostr.EventPointer{
|
||||
ID: "31d7c2875b5fc8e6f9c8f9dc1f84de1b6b91d1947ea4c59225e55c325d330fa8",
|
||||
Relays: []string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Text: "nostr:nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg",
|
||||
Text: "nostr:nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg",
|
||||
Start: 47,
|
||||
End: 123,
|
||||
Profile: &nostr.ProfilePointer{
|
||||
PublicKey: "cc6b9fea033f59c3c39a0407c5f1bfee439b077508d918cfdc0d6fd431d39393",
|
||||
Relays: []string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Text: "nostr:nevent1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8ychxp5v4",
|
||||
Text: "nostr:nevent1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8ychxp5v4",
|
||||
Start: 127,
|
||||
End: 201,
|
||||
Event: &nostr.EventPointer{
|
||||
ID: "cc6b9fea033f59c3c39a0407c5f1bfee439b077508d918cfdc0d6fd431d39393",
|
||||
Relays: []string{},
|
||||
@@ -61,6 +69,14 @@ func TestParseReferences(t *testing.T) {
|
||||
t.Errorf("%d: got text %s, expected %s", i, g.Text, e.Text)
|
||||
}
|
||||
|
||||
if g.Start != e.Start {
|
||||
t.Errorf("%d: got start %d, expected %d", i, g.Start, e.Start)
|
||||
}
|
||||
|
||||
if g.End != e.End {
|
||||
t.Errorf("%d: got end %d, expected %d", i, g.End, e.End)
|
||||
}
|
||||
|
||||
if (g.Entity == nil && e.Entity != nil) ||
|
||||
(g.Event == nil && e.Event != nil) ||
|
||||
(g.Profile == nil && e.Profile != nil) {
|
||||
|
||||
Reference in New Issue
Block a user