github.com/diamondburned/arikawa/v2@v2.1.0/bot/extras/arguments/mention_test.go (about)

     1  package arguments
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/diamondburned/arikawa/v2/discord"
     7  )
     8  
     9  func TestChannelMention(t *testing.T) {
    10  	test := new(ChannelMention)
    11  	str := "<#123123>"
    12  	var id discord.ChannelID = 123123
    13  
    14  	if err := test.Parse(str); err != nil {
    15  		t.Fatal("Expected", id, "error:", err)
    16  	}
    17  
    18  	if actualID := test.ID(); actualID != id {
    19  		t.Fatal("Expected", id, "got", id)
    20  	}
    21  
    22  	if mention := test.Mention(); mention != str {
    23  		t.Fatal("Expected", str, "got", mention)
    24  	}
    25  }
    26  
    27  func TestUserMention(t *testing.T) {
    28  	test := new(UserMention)
    29  	str := "<@123123>"
    30  	var id discord.UserID = 123123
    31  
    32  	if err := test.Parse(str); err != nil {
    33  		t.Fatal("Expected", id, "error:", err)
    34  	}
    35  
    36  	if actualID := test.ID(); actualID != id {
    37  		t.Fatal("Expected", id, "got", id)
    38  	}
    39  
    40  	if mention := test.Mention(); mention != str {
    41  		t.Fatal("Expected", str, "got", mention)
    42  	}
    43  }
    44  
    45  func TestRoleMention(t *testing.T) {
    46  	test := new(RoleMention)
    47  	str := "<@&123123>"
    48  	var id discord.RoleID = 123123
    49  
    50  	if err := test.Parse(str); err != nil {
    51  		t.Fatal("Expected", id, "error:", err)
    52  	}
    53  
    54  	if actualID := test.ID(); actualID != id {
    55  		t.Fatal("Expected", id, "got", id)
    56  	}
    57  
    58  	if mention := test.Mention(); mention != str {
    59  		t.Fatal("Expected", str, "got", mention)
    60  	}
    61  }