-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
price_test.go
51 lines (41 loc) · 1.11 KB
/
price_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
package faker
import (
"reflect"
"strings"
"testing"
"github.com/go-faker/faker/v4/pkg/slice"
)
func TestCurrency(t *testing.T) {
p, err := GetPrice().Currency(reflect.Value{})
if err != nil {
t.Error("Expected not error, got err", err)
}
if !slice.Contains(currencies, p.(string)) {
t.Error("Expected a currency code from currencies")
}
}
func TestAmountWithCurrency(t *testing.T) {
p, err := GetPrice().AmountWithCurrency(reflect.Value{})
if err != nil {
t.Error("Expected not error, got err", err)
}
if !strings.Contains(p.(string), " ") {
t.Error("Expected Price currency followed by a space and it's amount")
}
}
func TestFakeCurrency(t *testing.T) {
p := Currency()
if !slice.Contains(currencies, p) {
t.Error("Expected a currency code from currencies")
}
}
func TestFakeAmountWithCurrency(t *testing.T) {
p := AmountWithCurrency()
if !strings.Contains(p, " ") {
t.Error("Expected Price currency followed by a space and it's amount")
}
arrCurrency := strings.Split(p, " ")
if !slice.Contains(currencies, arrCurrency[0]) {
t.Error("Expected a currency code from currencies")
}
}