dispatch/server/index_data_test.go
2017-06-13 04:25:59 +02:00

44 lines
794 B
Go

package server
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetTabFromPath(t *testing.T) {
cases := []struct {
input string
expectedServer string
expectedChannel string
}{
{
"/chat.freenode.net/%23r%2Fstuff%2F/",
"chat.freenode.net",
"#r/stuff/",
}, {
"/chat.freenode.net/%23r%2Fstuff%2F",
"chat.freenode.net",
"#r/stuff/",
}, {
"/chat.freenode.net/%23r%2Fstuff",
"chat.freenode.net",
"#r/stuff",
}, {
"/chat.freenode.net/%23stuff",
"chat.freenode.net",
"#stuff",
}, {
"/chat.freenode.net/%23stuff/cake",
"",
"",
},
}
for _, tc := range cases {
server, channel := getTabFromPath(tc.input)
assert.Equal(t, tc.expectedServer, server)
assert.Equal(t, tc.expectedChannel, channel)
}
}