@@ -137,3 +137,46 @@ test('this.get() to access the content', function(assert) {
137
137
changeset . save ( ) ;
138
138
assert . ok ( changeset . get ( 'isValid' ) , 'valid' ) ;
139
139
} ) ;
140
+
141
+ test ( 'this.get() has the same semantics as Ember.get when accessing content' , function ( assert ) {
142
+ const Validations = {
143
+ paymentMethod : validatePresence ( true ) ,
144
+ creditCardNumber : validateSometimes ( [
145
+ validatePresence ( true ) ,
146
+ validateLength ( { is : 16 } )
147
+ ] , function ( ) {
148
+ return this . get ( 'paymentMethod.isCreditCard' ) ;
149
+ } )
150
+ } ;
151
+
152
+ let settings = {
153
+ paymentMethod : {
154
+ isCreditCard : true
155
+ } ,
156
+ creditCardNumber : 12
157
+ } ;
158
+ let changeset = new Changeset ( settings , lookupValidator ( Validations ) , Validations ) ;
159
+ changeset . validate ( ) ;
160
+ assert . notOk ( changeset . get ( 'isValid' ) ) ;
161
+ } ) ;
162
+
163
+ test ( 'this.get() has the same semantics as Ember.get when accessing changes' , function ( assert ) {
164
+ const Validations = {
165
+ paymentMethod : validatePresence ( true ) ,
166
+ creditCardNumber : validateSometimes ( [
167
+ validatePresence ( true ) ,
168
+ validateLength ( { is : 16 } )
169
+ ] , function ( ) {
170
+ return this . get ( 'paymentMethod.isCreditCard' ) ;
171
+ } )
172
+ } ;
173
+
174
+ let settings = { } ;
175
+ let changeset = new Changeset ( settings , lookupValidator ( Validations ) , Validations ) ;
176
+ changeset . set ( 'paymentMethod' , {
177
+ isCreditCard : true
178
+ } ) ;
179
+ changeset . set ( 'creditCardNumber' , '12' ) ;
180
+ changeset . validate ( ) ;
181
+ assert . notOk ( changeset . get ( 'isValid' ) ) ;
182
+ } ) ;
0 commit comments