@@ -120,12 +120,9 @@ describe('MapperService', () => {
120120 Two : 6.53 , // ignored
121121 } ;
122122 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 ( ) ;
126123 expect ( warned ) . toBeNull ( ) ;
127124 } ) ) ;
128- it ( 'should warn when extraneous source properties.' ,
125+ it ( 'should warn when extraneous source properties, by default .' ,
129126 inject ( [ MapperService ] , ( mapper : MapperService ) => {
130127 var warned = null ;
131128 mapper [ "log" ] . warn = function ( yep ) { warned = yep ; } ;
@@ -135,9 +132,45 @@ describe('MapperService', () => {
135132 Two : 6.53 , // ignored
136133 } ;
137134 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 ) ;
141174 expect ( warned ) . toBeTruthy ( ) ;
142175 } ) ) ;
143176 it ( 'should not warn when not extraneous source properties.' ,
0 commit comments