aboutsummaryrefslogtreecommitdiffstats
path: root/ship_test.go
blob: b91e67162bac85202342d90be75315f753aef44b (plain) (blame)
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 lulu

import (
	"testing"
)

func TestMarshalUnmarshalShippingAddress(t *testing.T) {
	for _, pair := range []struct {
		j    string
		addr ShippingAddress
	}{
		{
			`{
				"city": "Lübeck",
				"country_code": "DE",
				"postcode": "23552",
				"state_code": "",
				"street1": "Holstenstr. 40",
				"phone_number": "844-212-0689"
			}`,
			ShippingAddress{
				"Lübeck",
				"DE",
				"23552",
				"", // TODO: does the API mind if this is "" instead of null?
				"Holstenstr. 40",
				"844-212-0689",
			},
		}, {
			`{
				"city": "Anytown",
				"country_code": "CA",
				"postcode": "A1A 1A1",
				"state_code": "QC",
				"street1": "123 Fake Street",
				"phone_number": "123-456-7890"
			}`,
			ShippingAddress{
				"Anytown",
				"CA",
				"A1A 1A1",
				"QC",
				"123 Fake Street",
				"123-456-7890",
			},
		},
	} {
		requireMarshalJsonEq(t, pair.j, pair.addr)
		requireUnmarshalJsonEq(t, pair.addr, pair.j)
	}
}