forked from bxcodec/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
price_test.go
55 lines (44 loc) · 1.16 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
52
53
54
55
package faker
import (
"reflect"
"strings"
"testing"
"github.com/bxcodec/faker/v3/support/slice"
)
func TestSetPrice(t *testing.T) {
SetPrice(Price{})
}
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")
}
}