-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrates_test.go
62 lines (53 loc) · 1.08 KB
/
rates_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
package vat
import (
"testing"
)
func TestStandardRate(t *testing.T) {
rate, ok := StandardRate("DE")
if !ok {
t.Error("should give rate for DE")
}
if rate != 19 {
t.Error("wrong rate for DE")
}
_, ok = StandardRate("de")
if !ok {
t.Error("should give rate for DE")
}
_, ok = StandardRate("ZZ")
if ok {
t.Error("don't give rate for unknown countries")
}
}
func TestStandardRateAtDate(t *testing.T) {
rate, ok := StandardRateAtDate("EL", since(2017, 5, 15))
if !ok {
t.Error("should give rate for EL")
}
if rate != 24 {
t.Errorf("wrong rate for EL since 2017-5-15: %v", rate)
}
rate, ok = StandardRateAtDate("EL", since(2016, 12, 30))
if !ok {
t.Error("should give rate for EL")
}
if rate != 23 {
t.Errorf("wrong rate for EL since 2016-12-30: %v", rate)
}
}
func TestIsEUCountry(t *testing.T) {
var tests = []struct {
countryCode string
isEUCountry bool
}{
{"DE", true},
{"AT", true},
{"CH", false},
{"XX", false},
}
for _, tt := range tests {
if tt.isEUCountry != IsEUCountry(tt.countryCode) {
t.Error("Country is not an eu country")
}
}
}