mchess-server/utils/passphrase_test.go
Marco d7c4f28f3a Fix endpoint for getting lobby id from passphrase
Had to add several helpers (e.g. passphrase ones) to make the endpoint
for getting lobby id work.

Moved all handler functions into handler package.

Added test for getting lobby from passphrase.
2024-05-09 22:29:48 +02:00

37 lines
814 B
Go

package utils
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_onlyUniqueWords(t *testing.T) {
wordsDistribution := make(map[string]int)
for _, word := range CleanWords {
wordsDistribution[word] += 1
}
for _, v := range wordsDistribution {
assert.Equal(t, 1, v)
}
assert.Equal(t, numberOfCleanWords, len(wordsDistribution))
}
func Test_Passphrase_AsURLParam(t *testing.T) {
phrase := NewPassphraseFromString("this is a Test phrase")
asParams := phrase.AsURLParam()
assert.Equal(t, "ThisIsATestPhrase", asParams)
}
func Test_Passphrase_ConvertToPassphraseWithSpaces(t *testing.T) {
fromURL := "ThisIsATestPhraseWithManyWords"
phrase := ConvertToPassphraseWithSpaces(fromURL)
assert.Equal(t, NewPassphraseFromString("this is a test phrase with many words"), phrase)
}