@@ -26,6 +26,7 @@ describe('Nodejs Optic nodes json constructor test', function () {
2626 { rowId : 4 , colorId : 1 , desc : 'hoop' } ,
2727 { rowId : 5 , colorId : 5 , desc : 'circle' }
2828 ] , 'myItem' ) ;
29+
2930 const plan2 =
3031 op . fromLiterals ( [
3132 { colorId : 1 , colorDesc : 'red' } ,
@@ -49,31 +50,18 @@ describe('Nodejs Optic nodes json constructor test', function () {
4950 op . prop ( 'array' , op . jsonArray ( [ op . jsonString ( op . col ( 'desc' ) ) , op . jsonNumber ( op . col ( 'rowId' ) ) ] ) )
5051 ] ) ) ) ,
5152 op . as ( 'node' , op . jsonString ( op . col ( 'desc' ) ) ) ,
52- op . as ( 'kind' , op . xdmp . nodeKind ( op . col ( 'node' ) ) ) ,
53- op . as ( 'xml' ,
54- op . xmlDocument (
55- op . xmlElement (
56- 'root' ,
57- op . xmlAttribute ( 'attrA' , op . col ( 'rowId' ) ) ,
58- [
59- op . xmlElement ( 'elemA' , null , op . viewCol ( 'myColor' , 'colorDesc' ) ) ,
60- op . xmlComment ( op . fn . concat ( 'this is a comment for ' , op . col ( 'desc' ) ) ) ,
61- op . xmlElement ( 'elemB' , null , op . col ( 'desc' ) )
62- ]
63- )
64- )
65- )
53+ op . as ( 'kind' , op . xdmp . nodeKind ( op . col ( 'node' ) ) )
6654 ] )
6755 . orderBy ( 'rowId' ) ;
56+
6857 db . rows . query ( output , { format : 'json' , structure : 'object' , columnTypes : 'header' } )
6958 . then ( function ( output ) {
70- // console.log(JSON.stringify(output, null, 2));
59+ console . log ( JSON . stringify ( output , null , 2 ) ) ;
7160 expect ( output . columns [ 1 ] . name ) . to . equal ( 'myJSON' ) ;
7261 expect ( output . columns [ 1 ] . type ) . to . equal ( 'object' ) ;
7362 expect ( output . columns [ 2 ] . name ) . to . equal ( 'node' ) ;
7463 expect ( output . columns [ 2 ] . type ) . to . equal ( 'text' ) ;
75- expect ( output . columns [ 4 ] . name ) . to . equal ( 'xml' ) ;
76- expect ( output . columns [ 4 ] . type ) . to . equal ( 'element' ) ;
64+
7765 expect ( output . rows . length ) . to . equal ( 4 ) ;
7866 expect ( output . rows [ 0 ] [ 'myItem.rowId' ] ) . to . equal ( 1 ) ;
7967 expect ( output . rows [ 0 ] . myJSON . str ) . to . equal ( 'ball' ) ;
@@ -86,9 +74,7 @@ describe('Nodejs Optic nodes json constructor test', function () {
8674 expect ( output . rows [ 0 ] . kind ) . to . equal ( 'text' ) ;
8775 expect ( output . rows [ 1 ] . myJSON . strFunc ) . to . equal ( '115 113 117 97 114 101' ) ;
8876 expect ( output . rows [ 1 ] . myJSON . mathFunc ) . to . equal ( 1.4142135623731 ) ;
89- expect ( output . rows [ 0 ] . xml ) . to . equal ( '<root attrA="1"><elemA>red</elemA><!--this is a comment for ball--><elemB>ball</elemB></root>' ) ;
9077 expect ( output . rows [ 3 ] [ 'myItem.rowId' ] ) . to . equal ( 4 ) ;
91- expect ( output . rows [ 3 ] . xml ) . to . equal ( '<root attrA="4"><elemA>red</elemA><!--this is a comment for hoop--><elemB>hoop</elemB></root>' ) ;
9278 done ( ) ;
9379 } ) . catch ( error => done ( error ) ) ;
9480 } ) ;
0 commit comments