2024-04-30 21:55:27 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2024-05-02 10:47:18 +00:00
|
|
|
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)
|
2024-04-30 21:55:27 +00:00
|
|
|
}
|
2024-05-02 10:47:18 +00:00
|
|
|
|
|
|
|
assert.Equal(t, numberOfCleanWords, len(wordsDistribution))
|
2024-04-30 21:55:27 +00:00
|
|
|
}
|
2024-05-09 20:29:48 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|