-
Notifications
You must be signed in to change notification settings - Fork 2
/
address_test.go
52 lines (44 loc) · 997 Bytes
/
address_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
package fatturapa
import (
"testing"
"github.com/invopop/gobl/org"
"github.com/stretchr/testify/assert"
)
func TestAddressRegion(t *testing.T) {
t.Run("should return the region two letter code", func(t *testing.T) {
addr := &org.Address{
Number: "1",
Street: "Via Roma",
Locality: "Roma",
Region: "RM",
Code: "00100",
Country: "IT",
}
out := newAddress(addr)
assert.Equal(t, "RM", out.Region)
})
t.Run("should ignore text name", func(t *testing.T) {
addr := &org.Address{
Number: "1",
Street: "Via Roma",
Locality: "Roma",
Region: "Rome",
Code: "00100",
Country: "IT",
}
out := newAddress(addr)
assert.Empty(t, out.Region)
})
t.Run("should ignore foreign addresses", func(t *testing.T) {
addr := &org.Address{
Number: "2",
Street: "Rome Street",
Locality: "London",
Region: "RM",
Code: "00100",
Country: "GB",
}
out := newAddress(addr)
assert.Empty(t, out.Region)
})
}