@@ -572,3 +572,85 @@ describe('Test the node with no handles attached when initializing', function ()
572572 assert . notStrictEqual ( node . getRMWImplementationIdentifier ( ) . length , 0 ) ;
573573 } ) ;
574574} ) ;
575+
576+ describe ( 'Node arguments' , function ( ) {
577+ this . timeout ( 60 * 1000 ) ;
578+
579+ it ( 'Test node arguments' , async function ( ) {
580+ await rclnodejs . init ( ) ;
581+ var node = rclnodejs . createNode (
582+ 'publisher' ,
583+ '/topic_getter' ,
584+ Context . defaultContext ( ) ,
585+ NodeOptions . defaultOptions ,
586+ [ '--ros-args' , '-r' , '__ns:=/foo/bar' ]
587+ ) ;
588+ assert . deepStrictEqual ( node . namespace ( ) , '/foo/bar' ) ;
589+ node . destroy ( ) ;
590+ rclnodejs . shutdown ( ) ;
591+ } ) ;
592+
593+ it ( 'Test node global arguments' , async function ( ) {
594+ await rclnodejs . init ( Context . defaultContext ( ) , [
595+ 'process_name' ,
596+ '--ros-args' ,
597+ '-r' ,
598+ '__node:=global_node_name' ,
599+ ] ) ;
600+ const node1 = rclnodejs . createNode (
601+ 'publisher' ,
602+ '/topic_getter' ,
603+ Context . defaultContext ( ) ,
604+ NodeOptions . defaultOptions ,
605+ [ '--ros-args' , '-r' , '__ns:=/foo/bar' ]
606+ ) ;
607+
608+ const node2 = rclnodejs . createNode (
609+ 'my_node' ,
610+ '/topic_getter' ,
611+ Context . defaultContext ( ) ,
612+ NodeOptions . defaultOptions ,
613+ [ ] ,
614+ false
615+ ) ;
616+
617+ assert . deepStrictEqual ( node1 . name ( ) , 'global_node_name' ) ;
618+ assert . deepStrictEqual ( node2 . name ( ) , 'my_node' ) ;
619+ node1 . destroy ( ) ;
620+ node2 . destroy ( ) ;
621+ rclnodejs . shutdown ( ) ;
622+ } ) ;
623+
624+ it ( 'Test node invalid arguments' , async function ( ) {
625+ await rclnodejs . init ( ) ;
626+ assert . throws (
627+ ( ) => {
628+ rclnodejs . createNode (
629+ 'invalid_node1' ,
630+ '/topic1' ,
631+ Context . defaultContext ( ) ,
632+ NodeOptions . defaultOptions ,
633+ [ '--ros-args' , '-r' , 'not-a-remap' ]
634+ ) ;
635+ } ,
636+ Error ,
637+ / f a i l e d t o p a r s e a r g u m e n t s /
638+ ) ;
639+
640+ assert . throws (
641+ ( ) => {
642+ rclnodejs . createNode (
643+ 'invalid_node2' ,
644+ '/topic2' ,
645+ Context . defaultContext ( ) ,
646+ NodeOptions . defaultOptions ,
647+ [ '--ros-args' , '--my-custom-flag' ]
648+ ) ;
649+ } ,
650+ Error ,
651+ / f a i l e d t o p a r s e a r g u m e n t s /
652+ ) ;
653+
654+ rclnodejs . shutdown ( ) ;
655+ } ) ;
656+ } ) ;
0 commit comments