diff --git a/frontend/src/pages/places.vue b/frontend/src/pages/places.vue index 89448cd3e..4eb4b3e62 100644 --- a/frontend/src/pages/places.vue +++ b/frontend/src/pages/places.vue @@ -130,11 +130,11 @@ const changed = Math.abs(this.query.lat - pos.lat) > 0.001 || Math.abs(this.query.long - pos.lng) > 0.001; + if(!changed) return; + this.query.lat = pos.lat.toString(); this.query.long = pos.lng.toString(); - if(!changed) return; - this.search(); }, startPos() { diff --git a/internal/util/keywords_test.go b/internal/util/keywords_test.go new file mode 100644 index 000000000..c99af5e12 --- /dev/null +++ b/internal/util/keywords_test.go @@ -0,0 +1,18 @@ +package util + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestKeywords(t *testing.T) { + t.Run("cat", func(t *testing.T) { + keywords := Keywords("cat") + assert.Equal(t, []string{"cat"}, keywords) + }) + t.Run("was", func(t *testing.T) { + keywords := Keywords("was") + assert.Equal(t, []string(nil), keywords) + }) +} diff --git a/internal/util/mime_test.go b/internal/util/mime_test.go new file mode 100644 index 000000000..2ee12d3a7 --- /dev/null +++ b/internal/util/mime_test.go @@ -0,0 +1,20 @@ +package util + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMimeType(t *testing.T) { + t.Run("jpg", func(t *testing.T) { + filename := ExpandedFilename("./testdata/test.jpg") + mimeType := MimeType(filename) + assert.Equal(t, "image/jpeg", mimeType) + }) + t.Run("not existing filename", func(t *testing.T) { + filename := ExpandedFilename("./testdata/xxx.jpg") + mimeType := MimeType(filename) + assert.Equal(t, "", mimeType) + }) +} diff --git a/internal/util/strings_test.go b/internal/util/strings_test.go index 87f49d784..09e268acf 100644 --- a/internal/util/strings_test.go +++ b/internal/util/strings_test.go @@ -6,6 +6,15 @@ import ( "github.com/stretchr/testify/assert" ) +func TestContainsNumber(t *testing.T) { + t.Run("True", func(t *testing.T) { + assert.Equal(t, true, ContainsNumber("f3abcde")) + }) + t.Run("False", func(t *testing.T) { + assert.Equal(t, false, ContainsNumber("abcd")) + }) +} + func TestIsSeparator(t *testing.T) { t.Run("rune A", func(t *testing.T) { assert.Equal(t, false, isSeparator('A')) diff --git a/internal/util/token_test.go b/internal/util/token_test.go new file mode 100644 index 000000000..296f23ca6 --- /dev/null +++ b/internal/util/token_test.go @@ -0,0 +1,29 @@ +package util + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestRandomToken(t *testing.T) { + t.Run("size 4", func(t *testing.T) { + token := RandomToken(4) + assert.NotEmpty(t, token) + }) + t.Run("size 8", func(t *testing.T) { + token := RandomToken(9) + assert.NotEmpty(t, token) + }) +} + +func TestUUID(t *testing.T) { + t.Run("size 4", func(t *testing.T) { + uuid := UUID() + assert.Equal(t, 36, len(uuid)) + }) + t.Run("size 8", func(t *testing.T) { + uuid := UUID() + assert.Equal(t, 36, len(uuid)) + }) +}