1+ const assert = require ( 'assert' ) ;
2+ const TestUtils = require ( "./TestUtils.js" ) ;
3+
4+ module . exports = function ( ) {
5+ function simplePrimitives ( ) {
6+ let i = undefined ;
7+ let i2 = null ;
8+ TestUtils . addLineLabel ( "done" , ( ) => TestUtils . getLineNumber ( ) )
9+ }
10+
11+ it ( 'add live log with undefined args' , async function ( ) {
12+ simplePrimitives ( ) //setup labels
13+
14+ await TestUtils . addLiveLog ( {
15+ "source" : TestUtils . getFilename ( ) ( ) ,
16+ "line" : TestUtils . getLineLabelNumber ( "done" )
17+ } , null , 1 , "arg i = {}, i2 = {}, i3 = {}" , [ "i" , "i2" , "i3" ] ) . then ( function ( res ) {
18+ assert . equal ( res . status , 200 ) ;
19+
20+ //trigger log (after listener is registered)
21+ setTimeout ( ( ) => simplePrimitives ( ) , 500 ) ;
22+ } ) . catch ( function ( err ) {
23+ assert . fail ( err )
24+ } ) ;
25+ } ) ;
26+
27+ it ( 'verify log data' , async function ( ) {
28+ this . timeout ( 200000 )
29+
30+ let event = await TestUtils . awaitMarkerEvent ( "LOG_HIT" ) ;
31+ let logResult = event . logResult
32+ assert . notEqual ( logResult , undefined ) ;
33+
34+ let logs = logResult . logs
35+ assert . notEqual ( logs , undefined ) ;
36+ assert . equal ( logs . length , 1 ) ;
37+
38+ let log = logs [ 0 ]
39+ assert . notEqual ( log , undefined ) ;
40+ assert . equal ( log . content , "arg i = {}, i2 = {}, i3 = {}" ) ;
41+
42+ let args = log . arguments
43+ assert . notEqual ( args , undefined ) ;
44+ assert . equal ( args . length , 3 ) ;
45+
46+ assert . equal ( args [ 0 ] , "undefined" ) ;
47+ assert . equal ( args [ 1 ] , "undefined" ) ;
48+ assert . equal ( args [ 2 ] , "undefined" ) ;
49+ } ) ;
50+ } ;
0 commit comments