@@ -5,13 +5,35 @@ const MOCK_CONTACT = Object.assign({}, getContactPrimary(MOCK_CASE), {
5
5
serviceIndicator : 'Electronic' ,
6
6
} ) ;
7
7
8
+ const MOCK_CONTACT_INTERNATIONAL = Object . assign ( { } , MOCK_CONTACT , {
9
+ country : 'Brazil' ,
10
+ serviceIndicator : 'Electronic' ,
11
+ } ) ;
12
+
8
13
describe ( 'marshallContact' , ( ) => {
9
14
it ( 'returns a contact object with the expected properties' , ( ) => {
10
15
expect ( Object . keys ( marshallContact ( MOCK_CONTACT ) ) . sort ( ) ) . toEqual ( [
11
16
'address1' ,
12
17
'address2' ,
13
18
'address3' ,
14
19
'city' ,
20
+ 'country' ,
21
+ 'email' ,
22
+ 'name' ,
23
+ 'phone' ,
24
+ 'postalCode' ,
25
+ 'serviceIndicator' ,
26
+ 'state' ,
27
+ ] ) ;
28
+
29
+ expect (
30
+ Object . keys ( marshallContact ( MOCK_CONTACT_INTERNATIONAL ) ) . sort ( ) ,
31
+ ) . toEqual ( [
32
+ 'address1' ,
33
+ 'address2' ,
34
+ 'address3' ,
35
+ 'city' ,
36
+ 'country' ,
15
37
'email' ,
16
38
'name' ,
17
39
'phone' ,
@@ -37,13 +59,48 @@ describe('marshallContact', () => {
37
59
expect ( mock . postalCode ) . toBeDefined ( ) ;
38
60
expect ( mock . serviceIndicator ) . toBeDefined ( ) ;
39
61
expect ( mock . state ) . toBeDefined ( ) ;
62
+ expect ( mock . country ) . toBeUndefined ( ) ; // undefined
63
+
64
+ const marshalled = marshallContact ( mock ) ;
65
+
66
+ expect ( marshalled . address1 ) . toEqual ( mock . address1 ) ;
67
+ expect ( marshalled . address2 ) . toEqual ( mock . address2 ) ;
68
+ expect ( marshalled . address3 ) . toEqual ( mock . address3 ) ;
69
+ expect ( marshalled . city ) . toEqual ( mock . city ) ;
70
+ expect ( marshalled . email ) . toEqual ( mock . email ) ;
71
+ expect ( marshalled . name ) . toEqual ( mock . name ) ;
72
+ expect ( marshalled . phone ) . toEqual ( mock . phone ) ;
73
+ expect ( marshalled . postalCode ) . toEqual ( mock . postalCode ) ;
74
+ expect ( marshalled . serviceIndicator ) . toEqual ( mock . serviceIndicator ) ;
75
+ expect ( marshalled . state ) . toEqual ( mock . state ) ;
76
+ expect ( marshalled . country ) . toEqual ( mock . country ) ;
77
+ } ) ;
78
+
79
+ it ( 'marshalls from the current contact format for users with a country' , ( ) => {
80
+ const mock = Object . assign ( { } , MOCK_CONTACT_INTERNATIONAL , {
81
+ address2 : 'address2' ,
82
+ address3 : 'address3' ,
83
+ } ) ;
84
+
85
+ expect ( mock . address1 ) . toBeDefined ( ) ;
86
+ expect ( mock . address2 ) . toBeDefined ( ) ;
87
+ expect ( mock . address3 ) . toBeDefined ( ) ;
88
+ expect ( mock . city ) . toBeDefined ( ) ;
89
+ expect ( mock . country ) . toBeDefined ( ) ;
90
+ expect ( mock . email ) . toBeDefined ( ) ;
91
+ expect ( mock . name ) . toBeDefined ( ) ;
92
+ expect ( mock . phone ) . toBeDefined ( ) ;
93
+ expect ( mock . postalCode ) . toBeDefined ( ) ;
94
+ expect ( mock . serviceIndicator ) . toBeDefined ( ) ;
95
+ expect ( mock . state ) . toBeDefined ( ) ;
40
96
41
97
const marshalled = marshallContact ( mock ) ;
42
98
43
99
expect ( marshalled . address1 ) . toEqual ( mock . address1 ) ;
44
100
expect ( marshalled . address2 ) . toEqual ( mock . address2 ) ;
45
101
expect ( marshalled . address3 ) . toEqual ( mock . address3 ) ;
46
102
expect ( marshalled . city ) . toEqual ( mock . city ) ;
103
+ expect ( marshalled . country ) . toEqual ( mock . country ) ;
47
104
expect ( marshalled . email ) . toEqual ( mock . email ) ;
48
105
expect ( marshalled . name ) . toEqual ( mock . name ) ;
49
106
expect ( marshalled . phone ) . toEqual ( mock . phone ) ;
0 commit comments