catalog_test.go 852 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package locale // import "miniflux.app/locale"
  5. import "testing"
  6. func TestParserWithInvalidData(t *testing.T) {
  7. _, err := parseTranslationDict(`{`)
  8. if err == nil {
  9. t.Fatal(`An error should be returned when parsing invalid data`)
  10. }
  11. }
  12. func TestParser(t *testing.T) {
  13. translations, err := parseTranslationDict(`{"k": "v"}`)
  14. if err != nil {
  15. t.Fatalf(`Unexpected parsing error: %v`, err)
  16. }
  17. if translations == nil {
  18. t.Fatal(`Translations should not be nil`)
  19. }
  20. value, found := translations["k"]
  21. if !found {
  22. t.Fatal(`The translation should contains the defined key`)
  23. }
  24. if value.(string) != "v" {
  25. t.Fatal(`The translation key should contains the defined value`)
  26. }
  27. }