-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathussd_test.go
78 lines (75 loc) · 1.53 KB
/
ussd_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package ravepay
import (
"reflect"
"testing"
)
func TestUSSD_ChargeURL(t *testing.T) {
type fields struct {
ChargeRequestURL string
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "returns the ChargeMpesaURL in the mpesa object if present",
fields: fields{"https://charge.ussd.url"},
want: "https://charge.ussd.url",
},
{
name: "set's the object ChargeMpesaURL to config's ChargeURL and returns it",
want: baseURL + defaultChargeURL,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &USSD{
ChargeRequestURL: tt.fields.ChargeRequestURL,
}
if got := c.ChargeURL(); got != tt.want {
t.Errorf("USSD.ChargeURL() = %v, want %v", got, tt.want)
}
})
}
}
func TestUSSDPaymentInstruction(t *testing.T) {
type args struct {
cr *ChargeResponse
}
tests := []struct {
name string
args args
want *USSDPaymentInfo
}{
{
name: "returns the ussd payment info-1",
args: args{
cr: &ChargeResponse{
Data: chargeResponseData{
Amount: 900,
FlwRef: "some-ref",
},
},
},
want: &USSDPaymentInfo{
Amount: 900,
FlwRef: "some-ref",
},
},
{
name: "returns teh ussd payment info-2",
args: args{
cr: &ChargeResponse{},
},
want: &USSDPaymentInfo{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := USSDPaymentInstruction(tt.args.cr); !reflect.DeepEqual(got, tt.want) {
t.Errorf("USSDPaymentInstruction() = %v, want %v", got, tt.want)
}
})
}
}