|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const chai = require('chai'); |
| 4 | +const expect = chai.expect; |
| 5 | +const rosnodejs = require('../src/index.js'); |
| 6 | + |
| 7 | +describe('messages', function () { |
| 8 | + |
| 9 | + it('real messages', function() { |
| 10 | + expect(rosnodejs.require('geometry_msgs')).to.not.be.empty; |
| 11 | + expect(rosnodejs.require('geometry_msgs').msg).to.not.be.empty; |
| 12 | + expect(rosnodejs.require('geometry_msgs').msg).to.have.keys( |
| 13 | + 'Accel','AccelStamped','AccelWithCovariance','AccelWithCovarianceStamped', |
| 14 | + 'Inertia','InertiaStamped','Point','Point32','PointStamped', |
| 15 | + 'Polygon','PolygonStamped','Pose','Pose2D','PoseArray','PoseStamped', |
| 16 | + 'PoseWithCovariance','PoseWithCovarianceStamped','Quaternion', |
| 17 | + 'QuaternionStamped','Transform','TransformStamped','Twist','TwistStamped', |
| 18 | + 'TwistWithCovariance','TwistWithCovarianceStamped','Vector3', |
| 19 | + 'Vector3Stamped','Wrench','WrenchStamped' |
| 20 | + ); |
| 21 | + expect(rosnodejs.require('geometry_msgs').srv).to.be.empty; |
| 22 | + |
| 23 | + expect(rosnodejs.require('std_msgs')).to.not.be.empty; |
| 24 | + expect(rosnodejs.require('std_msgs').msg).to.not.be.empty; |
| 25 | + expect(rosnodejs.require('std_msgs').msg).to.have.keys( |
| 26 | + 'Bool','Duration','Float64MultiArray','Int32MultiArray', |
| 27 | + 'MultiArrayDimension','UInt16MultiArray','UInt8','Byte','Empty','Header', |
| 28 | + 'Int64','MultiArrayLayout','UInt32','UInt8MultiArray','ByteMultiArray', |
| 29 | + 'Float32','Int16','Int64MultiArray','String','UInt32MultiArray','Char', |
| 30 | + 'Float32MultiArray','Int16MultiArray','Int8','Time','UInt64','ColorRGBA', |
| 31 | + 'Float64','Int32','Int8MultiArray','UInt16','UInt64MultiArray' |
| 32 | + ) |
| 33 | + expect(rosnodejs.require('std_msgs').srv).to.be.empty; |
| 34 | + |
| 35 | + expect(rosnodejs.require('std_srvs')).to.not.be.empty; |
| 36 | + expect(rosnodejs.require('std_srvs').msg).to.be.empty; |
| 37 | + expect(rosnodejs.require('std_srvs').srv).to.not.be.empty; |
| 38 | + expect(rosnodejs.require('std_srvs').srv).to.have.keys( |
| 39 | + 'Empty','SetBool','Trigger' |
| 40 | + ); |
| 41 | + |
| 42 | + expect(rosnodejs.require('test_msgs')).to.not.be.empty; |
| 43 | + expect(rosnodejs.require('test_msgs').msg).to.not.be.empty; |
| 44 | + expect(rosnodejs.require('test_msgs').msg).to.have.keys( |
| 45 | + 'AllTypes','BaseTypeConstantLengthArray','ConstantLengthArray', |
| 46 | + 'VariableLengthArray','BaseType','BaseTypeVariableLengthArray','StdMsg', |
| 47 | + "TestActionAction","TestActionActionFeedback","TestActionActionGoal", |
| 48 | + "TestActionActionResult","TestActionFeedback","TestActionGoal", |
| 49 | + "TestActionResult" |
| 50 | + ); |
| 51 | + expect(rosnodejs.require('test_msgs').srv).to.not.be.empty; |
| 52 | + expect(rosnodejs.require('test_msgs').srv).to.have.keys( |
| 53 | + 'BasicService','HeaderService','NonSpecServiceDivider','TestService' |
| 54 | + ); |
| 55 | + }); |
| 56 | + |
| 57 | + it('non-existant messages', function() { |
| 58 | + const nonExistantPkg = 'made_up_message_package'; |
| 59 | + expect(rosnodejs.require.bind(rosnodejs, nonExistantPkg)).to.throw( |
| 60 | + Error, `Unable to find message package ${nonExistantPkg} from CMAKE_PREFIX_PATH` |
| 61 | + ); |
| 62 | + }); |
| 63 | +}); |
0 commit comments