@@ -40,37 +40,37 @@ describe('IntlTelInputComponent', () => {
40
40
} ) ;
41
41
42
42
it ( 'should convert phone number to E164 format' , ( ) => {
43
- component . options = {
43
+ component . options . set ( {
44
44
preferredCountries : [ 'ch' ] ,
45
45
onlyCountries : [ 'ch' , 'fr' ]
46
- } ;
46
+ } ) ;
47
47
component . ngAfterViewInit ( ) ;
48
48
49
49
component . phoneNumber = '0797703808' ;
50
50
51
- expect ( component . E164PhoneNumber ) . toBe ( '+41797703808' ) ;
51
+ expect ( component . E164PhoneNumber ( ) ) . toBe ( '+41797703808' ) ;
52
52
} ) ;
53
53
54
54
it ( 'should re-set E164 phone number on countryChange' , ( ) => {
55
- component . options = {
55
+ component . options . set ( {
56
56
preferredCountries : [ 'ch' ] ,
57
57
onlyCountries : [ 'ch' , 'fr' ]
58
- } ;
58
+ } ) ;
59
59
component . ngAfterViewInit ( ) ;
60
60
61
61
component . phoneNumber = '0797703808' ;
62
62
63
- expect ( component . E164PhoneNumber ) . toBe ( '+41797703808' ) ;
63
+ expect ( component . E164PhoneNumber ( ) ) . toBe ( '+41797703808' ) ;
64
64
65
65
component . phoneNumber = '0681215656' ;
66
66
component . intlTelInput . setCountry ( 'fr' ) ;
67
67
68
- expect ( component . E164PhoneNumber ) . toBe ( '+33681215656' ) ;
68
+ expect ( component . E164PhoneNumber ( ) ) . toBe ( '+33681215656' ) ;
69
69
} ) ;
70
70
71
71
it ( 'should add a label tag if label attribute is set' , ( ) => {
72
72
const labelText = 'label text' ;
73
- component . label = labelText ;
73
+ component . label . set ( labelText ) ;
74
74
fixture . detectChanges ( ) ;
75
75
76
76
const element = fixture
@@ -91,7 +91,7 @@ describe('IntlTelInputComponent', () => {
91
91
} ) ;
92
92
93
93
it ( 'should not have a css class by default for the label' , ( ) => {
94
- component . label = 'label' ;
94
+ component . label . set ( 'label' ) ;
95
95
fixture . detectChanges ( ) ;
96
96
97
97
const element = fixture
@@ -103,20 +103,20 @@ describe('IntlTelInputComponent', () => {
103
103
} ) ;
104
104
105
105
it ( 'should be possible to specify a css class for the label' , ( ) => {
106
- component . label = 'label' ;
107
- component . labelCssClass = 'label-css-class' ;
106
+ component . label . set ( 'label' ) ;
107
+ component . labelCssClass . set ( 'label-css-class' ) ;
108
108
fixture . detectChanges ( ) ;
109
109
110
110
const element = fixture
111
111
. debugElement
112
112
. query ( By . css ( 'label' ) )
113
113
. nativeElement ;
114
114
115
- expect ( element . className ) . toContain ( component . labelCssClass ) ;
115
+ expect ( element . className ) . toContain ( component . labelCssClass ( ) ) ;
116
116
} ) ;
117
117
118
118
it ( 'should set both required and aria-required if specified' , ( ) => {
119
- component . required = true ;
119
+ component . required . set ( true ) ;
120
120
fixture . detectChanges ( ) ;
121
121
122
122
const element : HTMLElement = fixture
@@ -134,26 +134,26 @@ describe('IntlTelInputComponent', () => {
134
134
. query ( By . css ( 'input' ) )
135
135
. nativeElement ;
136
136
137
- expect ( element . getAttribute ( 'name' ) ) . toBe ( component . name ) ;
137
+ expect ( element . getAttribute ( 'name' ) ) . toBe ( component . name ( ) ) ;
138
138
expect ( element . getAttribute ( 'name' ) ) . toBe ( element . getAttribute ( 'id' ) ) ;
139
139
} ) ;
140
140
141
141
it ( 'should set name and id to the same value' , ( ) => {
142
- component . name = 'custom-name' ;
142
+ component . name . set ( 'custom-name' ) ;
143
143
fixture . detectChanges ( ) ;
144
144
145
145
const element : HTMLElement = fixture
146
146
. debugElement
147
147
. query ( By . css ( 'input' ) )
148
148
. nativeElement ;
149
-
150
- expect ( element . getAttribute ( 'name' ) ) . toBe ( component . name ) ;
149
+ console . log ( component . name ( ) ) ;
150
+ expect ( element . getAttribute ( 'name' ) ) . toBe ( component . name ( ) ) ;
151
151
expect ( element . getAttribute ( 'name' ) ) . toBe ( element . getAttribute ( 'id' ) ) ;
152
152
} ) ;
153
153
154
154
it ( 'should allow specifying a css class' , ( ) => {
155
155
const cssClass = 'my-css-class' ;
156
- component . cssClass = cssClass ;
156
+ component . cssClass . set ( cssClass ) ;
157
157
fixture . detectChanges ( ) ;
158
158
159
159
const element : HTMLElement = fixture
@@ -165,32 +165,33 @@ describe('IntlTelInputComponent', () => {
165
165
} ) ;
166
166
167
167
it ( 'should be possible to set preferredCountries option' , ( ) => {
168
- component . options = {
168
+ component . options . set ( {
169
169
countrySearch : false ,
170
170
preferredCountries : [ 'ch' ] ,
171
171
onlyCountries : [ 'ch' ]
172
- } ;
172
+ } ) ;
173
173
component . ngAfterViewInit ( ) ;
174
174
175
175
fixture . detectChanges ( ) ;
176
-
176
+ console . log ( fixture
177
+ . debugElement ) ;
177
178
const element = fixture
178
179
. debugElement
179
180
. query ( By . css ( '#intl-tel-input-name' ) )
180
181
. nativeElement
181
182
. parentNode
182
183
. querySelector ( '.iti__preferred' ) ;
183
184
184
- expect ( element . getAttribute ( 'data-country-code' ) ) . toBe ( component . options . onlyCountries ?. [ 0 ] ) ;
185
+ expect ( element . getAttribute ( 'data-country-code' ) ) . toBe ( component . options ( ) . onlyCountries ?. [ 0 ] ) ;
185
186
} ) ;
186
187
187
188
it ( 'should be possible to set i18n option' , ( ) => {
188
189
const localizedCountryName = 'Suisse' ;
189
- component . options = {
190
+ component . options . set ( {
190
191
preferredCountries : [ 'ch' ] ,
191
192
i18n : { ch : localizedCountryName } ,
192
193
onlyCountries : [ 'ch' ]
193
- } ;
194
+ } ) ;
194
195
component . ngAfterViewInit ( ) ;
195
196
196
197
fixture . detectChanges ( ) ;
0 commit comments