@@ -7,7 +7,24 @@ describe("commands-history", () => {
77 describe ( "utils" , ( ) => {
88 describe ( "normalizeCommandArgs" , ( ) => {
99 it ( "should return representation for an object" , ( ) => {
10- assert . deepEqual ( normalizeCommandArgs ( "click" , [ { some : "data" } ] ) , [ "obj" ] ) ;
10+ assert . deepEqual ( normalizeCommandArgs ( "click" , [ { some : "data" } ] ) , [ "{ some: 'data' }" ] ) ;
11+ } ) ;
12+
13+ it ( "should handle large objects" , ( ) => {
14+ const largeObject = {
15+ some : {
16+ nested : {
17+ data : "data" ,
18+ } ,
19+ } ,
20+ field : "value" ,
21+ array : [ 1 , 2 , 3 , 4 , { some : "data" } ] ,
22+ longString : "abc" . repeat ( 100 ) ,
23+ } ;
24+
25+ assert . deepEqual ( normalizeCommandArgs ( "click" , [ largeObject ] ) , [
26+ "{ some: [Object], field: 'value', array: [Array..." ,
27+ ] ) ;
1128 } ) ;
1229
1330 it ( 'should return truncated representation for the "execute" command' , ( ) => {
@@ -25,6 +42,22 @@ describe("commands-history", () => {
2542 it ( "should convert argument to string if it is not string or object" , ( ) => {
2643 assert . deepEqual ( normalizeCommandArgs ( "click" , [ false , null , 100 ] ) , [ "false" , "null" , "100" ] ) ;
2744 } ) ;
45+
46+ it ( "should return 'promise' for promise arguments" , ( ) => {
47+ const promiseArg = Promise . resolve ( "test" ) ;
48+
49+ assert . deepEqual ( normalizeCommandArgs ( "click" , [ promiseArg ] ) , [ "promise" ] ) ;
50+ } ) ;
51+
52+ it ( "should return 'unknown' if error occurs during argument normalization" , ( ) => {
53+ const problematicArg = Object . create ( {
54+ toString : ( ) => {
55+ throw new Error ( "Cannot convert to string" ) ;
56+ } ,
57+ } ) ;
58+
59+ assert . deepEqual ( normalizeCommandArgs ( "click" , [ problematicArg ] ) , [ "unknown" ] ) ;
60+ } ) ;
2861 } ) ;
2962
3063 describe ( "runWithHooks" , ( ) => {
0 commit comments