File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -818,3 +818,37 @@ describe('Log Splitting', function() {
818818 } ) ;
819819 } ) ;
820820} ) ;
821+ describe ( 'EventhubLogHandler Fix Properties Json String' , function ( ) {
822+
823+ beforeEach ( function ( ) {
824+ this . forwarder = setUp ( ) ;
825+ } ) ;
826+
827+ it ( 'parses properties string with single quotes into object' , function ( ) {
828+ const record = { properties : "{'key':'value'}" } ;
829+ const result = this . forwarder . fixPropertiesJsonString ( record ) ;
830+ assert . equal (
831+ 'object' ,
832+ typeof result . properties
833+ )
834+ } ) ;
835+
836+ it ( "leaves properties string unchanged when it doesn't match the malformed pattern" , function ( ) {
837+ const record = { properties : 'some plain string without colons' } ;
838+ const result = this . forwarder . fixPropertiesJsonString ( record ) ;
839+ assert . equal (
840+ 'string' ,
841+ typeof result . properties
842+ )
843+ } ) ;
844+
845+ it ( 'logs an error and returns original record when replacement results in invalid JSON' , function ( ) {
846+ // includes the "':'" marker so the function attempts replacement, but JSON remains invalid
847+ const badRecord = { properties : "Look i know i shouldn't but, i will do this ':' " } ;
848+ const result = this . forwarder . fixPropertiesJsonString ( badRecord ) ;
849+ assert . equal (
850+ 'string' ,
851+ typeof result . properties
852+ )
853+ } ) ;
854+ } ) ;
You can’t perform that action at this time.
0 commit comments