forked from urdt/ussd
update tests
This commit is contained in:
parent
abbf22086f
commit
204ce3ce56
@ -504,3 +504,35 @@ func TestMyAccount_Edit_offerings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMyAccount_View_Profile(t *testing.T) {
|
||||
en, fn := enginetest.TestEngine("session1234112")
|
||||
defer fn()
|
||||
ctx := context.Background()
|
||||
sessions := testData
|
||||
for _, session := range sessions {
|
||||
groups := driver.FilterGroupsByName(session.Groups, "menu_my_account_view_profile")
|
||||
for _, group := range groups {
|
||||
for index, step := range group.Steps {
|
||||
t.Logf("step %v with input %v", index, step.Input)
|
||||
cont, err := en.Exec(ctx, []byte(step.Input))
|
||||
if err != nil {
|
||||
t.Errorf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
||||
return
|
||||
}
|
||||
if !cont {
|
||||
break
|
||||
}
|
||||
w := bytes.NewBuffer(nil)
|
||||
if _, err := en.Flush(ctx, w); err != nil {
|
||||
t.Errorf("Test case '%s' failed during Flush: %v", group.Name, err)
|
||||
}
|
||||
b := w.Bytes()
|
||||
if !bytes.Equal(b, []byte(step.ExpectedContent)) {
|
||||
t.Fatalf("expected:\n\t%s\ngot:\n\t%s\n", step.ExpectedContent, b)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,11 +324,11 @@
|
||||
"expectedContent": "My profile\n1:Edit name\n2:Edit family name\n3:Edit gender\n4:Edit year of birth\n5:Edit location\n6:Edit offerings\n7:View profile\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "3",
|
||||
"input": "2",
|
||||
"expectedContent": "Select gender: \n1:Male\n2:Female\n3:Unspecified\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "foo",
|
||||
"input": "Female",
|
||||
"expectedContent": "Please enter your PIN:"
|
||||
},
|
||||
{
|
||||
@ -396,7 +396,7 @@
|
||||
"expectedContent": "Enter your location:\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "1945",
|
||||
"input": "Kilifi",
|
||||
"expectedContent": "Please enter your PIN:"
|
||||
},
|
||||
{
|
||||
@ -430,7 +430,7 @@
|
||||
"expectedContent": "Enter the services or goods you offer: \n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "1945",
|
||||
"input": "Bananas",
|
||||
"expectedContent": "Please enter your PIN:"
|
||||
},
|
||||
{
|
||||
@ -442,6 +442,45 @@
|
||||
"expectedContent": "Thank you for using Sarafu. Goodbye!"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "menu_my_account_view_profile",
|
||||
"steps": [
|
||||
{
|
||||
|
||||
"input": "",
|
||||
"expectedContent":"Balance: 0.003 CELO\n\n1:Send\n2:My Vouchers\n3:My Account\n4:Help\n9:Quit"
|
||||
},
|
||||
{
|
||||
"input": "3",
|
||||
"expectedContent": "My Account\n1:Profile\n2:Change language\n3:Check balances\n4:Check statement\n5:PIN options\n6:My Address\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "1",
|
||||
"expectedContent": "My profile\n1:Edit name\n2:Edit family name\n3:Edit gender\n4:Edit year of birth\n5:Edit location\n6:Edit offerings\n7:View profile\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "7",
|
||||
"expectedContent": "Please enter your PIN:"
|
||||
},
|
||||
{
|
||||
"input": "1234",
|
||||
"expectedContent": "My profile:\nName: foo foo\nGender: foo\nAge: 79\nLocation: 1945\nYou provide: 1945\n\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "0",
|
||||
"expectedContent": "My profile\n1:Edit name\n2:Edit family name\n3:Edit gender\n4:Edit year of birth\n5:Edit location\n6:Edit offerings\n7:View profile\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "0",
|
||||
"expectedContent": "My Account\n1:Profile\n2:Change language\n3:Check balances\n4:Check statement\n5:PIN options\n6:My Address\n0:Back"
|
||||
},
|
||||
{
|
||||
|
||||
"input": "9",
|
||||
"expectedContent":""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user