Skip to content

Commit 7eb3fd7

Browse files
Add test to do Get from a variable.
1 parent 9a4f037 commit 7eb3fd7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

domain_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,22 @@ msgstr ""
179179
t.Errorf("Exported PO format does not match. Received:\n\n%v\n\n\nExpected:\n\n%v", string(poBytes), expectedOutput)
180180
}
181181
}
182+
183+
func TestDomain_GetWithVar(t *testing.T) {
184+
po := NewPo()
185+
po.ParseFile(enUSFixture)
186+
187+
domain := po.GetDomain()
188+
189+
// Test singular with variable
190+
v := "My Text"
191+
tr := domain.Get(v)
192+
if tr != "My Text" {
193+
t.Errorf("Expected 'MyText' but got '%s'", tr)
194+
}
195+
196+
tr = po.Get(v)
197+
if tr != "My Text" {
198+
t.Errorf("Expected 'MyText' but got '%s'", tr)
199+
}
200+
}

po_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ func TestPo_Get(t *testing.T) {
3434
if tr != translatedText {
3535
t.Errorf("Expected '%s' but got '%s'", translatedText, tr)
3636
}
37+
38+
v := "My text"
39+
tr = po.Get(v)
40+
if tr != translatedText {
41+
t.Errorf("Expected '%s' but got '%s'", translatedText, tr)
42+
}
43+
3744
// Test translations
3845
tr = po.Get("language")
3946
if tr != "en_US" {

0 commit comments

Comments
 (0)