@@ -193,5 +193,33 @@ describe("Get Json diff representation", function() {
193193 expect ( result . diff [ 1 ] . key ) . toEqual ( "a" ) ;
194194 expect ( result . diff [ 1 ] . op ) . toEqual ( REMOVE ) ;
195195 expect ( result . diff [ 1 ] . valueType ) . toEqual ( SCALAR ) ;
196- } )
196+ } ) ;
197+
198+ it ( "Diff should throw exception with correct error message when left json is invalid" , function ( ) {
199+ var call = function ( ) {
200+ getDiffRepresentation ( "Oh, how I wish you were here now..." , "{\"a\":\"1\"}" ) ;
201+ } ;
202+ expect ( call ) . toThrow ( new ValidationException ( "Input is not a valid JSON" , null ) ) ;
203+ } ) ;
204+
205+ it ( "Diff should throw exception with correct error message when right json is invalid" , function ( ) {
206+ var call = function ( ) {
207+ getDiffRepresentation ( "{\"a\":\"1\"}" , "... we were just two lost souls" ) ;
208+ } ;
209+ expect ( call ) . toThrow ( new ValidationException ( null , "Input is not a valid JSON" ) ) ;
210+ } ) ;
211+
212+ it ( "Diff should throw exception with correct error message when left and right json is invalid" , function ( ) {
213+ var call = function ( ) {
214+ getDiffRepresentation ( "... swimming in a fish bowl..." , "... year after year." ) ;
215+ } ;
216+ expect ( call ) . toThrow ( new ValidationException ( "Input is not a valid JSON" , "Input is not a valid JSON" ) ) ;
217+ } ) ;
218+
219+ it ( "Diff should throw exception with correct error message when one of jsons is scalar" , function ( ) {
220+ var call = function ( ) {
221+ getDiffRepresentation ( "11" , "{}" ) ;
222+ } ;
223+ expect ( call ) . toThrow ( new ValidationException ( "Input is not a valid JSON" , null ) ) ;
224+ } ) ;
197225} ) ;
0 commit comments