@@ -120,12 +120,9 @@ describe('MapperService', () => {
120
120
Two : 6.53 , // ignored
121
121
} ;
122
122
var result = mapper . MapJsonToVM ( vm . MineMinusTwo , json , false ) ;
123
- expect ( result . Id ) . toBe ( 3 ) ;
124
- expect ( result . One ) . toBe ( json . One ) ;
125
- expect ( result [ "Two" ] ) . toBeUndefined ( ) ;
126
123
expect ( warned ) . toBeNull ( ) ;
127
124
} ) ) ;
128
- it ( 'should warn when extraneous source properties.' ,
125
+ it ( 'should warn when extraneous source properties, by default .' ,
129
126
inject ( [ MapperService ] , ( mapper : MapperService ) => {
130
127
var warned = null ;
131
128
mapper [ "log" ] . warn = function ( yep ) { warned = yep ; } ;
@@ -135,9 +132,45 @@ describe('MapperService', () => {
135
132
Two : 6.53 , // ignored
136
133
} ;
137
134
var result = mapper . MapJsonToVM ( vm . MineMinusTwo , json ) ;
138
- expect ( result . Id ) . toBe ( 3 ) ;
139
- expect ( result . One ) . toBe ( json . One ) ;
140
- expect ( result [ "Two" ] ) . toBeUndefined ( ) ;
135
+ expect ( warned ) . toBeTruthy ( ) ;
136
+ } ) ) ;
137
+ it ( 'should warn when extraneous source properties when global=off, method=on (overrides global).' ,
138
+ inject ( [ MapperService ] , ( mapper : MapperService ) => {
139
+ var warned = null ;
140
+ mapper [ "noUnmappedWarnings" ] = true ;
141
+ mapper [ "log" ] . warn = function ( yep ) { warned = yep ; } ;
142
+ var json = {
143
+ Id : 3 ,
144
+ One : "something else" ,
145
+ Two : 6.53 , // ignored
146
+ } ;
147
+ var result = mapper . MapJsonToVM ( vm . MineMinusTwo , json , true ) ;
148
+ expect ( warned ) . toBeTruthy ( ) ;
149
+ } ) ) ;
150
+ it ( 'should not warn when extraneous source properties when global=on, method=off (overrides global).' ,
151
+ inject ( [ MapperService ] , ( mapper : MapperService ) => {
152
+ var warned = null ;
153
+ mapper [ "noUnmappedWarnings" ] = false ;
154
+ mapper [ "log" ] . warn = function ( yep ) { warned = yep ; } ;
155
+ var json = {
156
+ Id : 3 ,
157
+ One : "something else" ,
158
+ Two : 6.53 , // ignored
159
+ } ;
160
+ var result = mapper . MapJsonToVM ( vm . MineMinusTwo , json , false ) ;
161
+ expect ( warned ) . toBeFalsy ( ) ;
162
+ } ) ) ;
163
+ it ( 'should warn when extraneous source properties when global=on, method=on (overrides global).' ,
164
+ inject ( [ MapperService ] , ( mapper : MapperService ) => {
165
+ var warned = null ;
166
+ mapper [ "noUnmappedWarnings" ] = false ;
167
+ mapper [ "log" ] . warn = function ( yep ) { warned = yep ; } ;
168
+ var json = {
169
+ Id : 3 ,
170
+ One : "something else" ,
171
+ Two : 6.53 , // ignored
172
+ } ;
173
+ var result = mapper . MapJsonToVM ( vm . MineMinusTwo , json , true ) ;
141
174
expect ( warned ) . toBeTruthy ( ) ;
142
175
} ) ) ;
143
176
it ( 'should not warn when not extraneous source properties.' ,
0 commit comments