@@ -15,6 +15,9 @@ describe("UrdfJoint", () => {
1515 jointWithAxisUrdf ,
1616 "text/xml" ,
1717 ) . documentElement ;
18+ if ( ! xml ) {
19+ throw new Error ( "Failed to parse XML" ) ;
20+ }
1821 const joint = new UrdfJoint ( { xml } ) ;
1922 expect ( joint . axis . x ) . toBe ( 0 ) ;
2023 expect ( joint . axis . y ) . toBe ( 1 ) ;
@@ -33,13 +36,16 @@ describe("UrdfJoint", () => {
3336 jointNoAxisUrdf ,
3437 "text/xml" ,
3538 ) . documentElement ;
39+ if ( ! xml ) {
40+ throw new Error ( "Failed to parse XML" ) ;
41+ }
3642 const joint = new UrdfJoint ( { xml } ) ;
3743 expect ( joint . axis . x ) . toBe ( 1 ) ;
3844 expect ( joint . axis . y ) . toBe ( 0 ) ;
3945 expect ( joint . axis . z ) . toBe ( 0 ) ;
4046 } ) ;
4147
42- it ( "should default axis to (1,0,0) if axis xyz is malformed" , ( ) => {
48+ it ( "should throw if axis xyz is malformed" , ( ) => {
4349 const jointMalformedAxisUrdf = `
4450 <joint name="test_joint" type="revolute">
4551 <parent link="link1"/>
@@ -52,9 +58,11 @@ describe("UrdfJoint", () => {
5258 jointMalformedAxisUrdf ,
5359 "text/xml" ,
5460 ) . documentElement ;
55- const joint = new UrdfJoint ( { xml } ) ;
56- expect ( joint . axis . x ) . toBe ( 1 ) ;
57- expect ( joint . axis . y ) . toBe ( 0 ) ;
58- expect ( joint . axis . z ) . toBe ( 0 ) ;
61+ if ( ! xml ) {
62+ throw new Error ( "Failed to parse XML" ) ;
63+ }
64+ expect ( ( ) => new UrdfJoint ( { xml } ) ) . toThrowError (
65+ "If specified, axis must have an xyz value composed of three numbers" ,
66+ ) ;
5967 } ) ;
6068} ) ;
0 commit comments