Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions test/test-message-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('Rclnodejs message type testing', function () {
'Bool_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The subscription destruction logic is duplicated across multiple tests. Consider extracting this cleanup code into a common teardown hook (e.g., an afterEach block) to improve maintainability and reduce code duplication.

Suggested change
node.destroySubscription(subscription);
currentSubscription = { node, subscription };

Copilot uses AI. Check for mistakes.
assert.deepStrictEqual(typeof msg.data, 'boolean');
assert.ok(msg.data);
done();
Expand All @@ -62,6 +63,7 @@ describe('Rclnodejs message type testing', function () {
'Char_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.deepStrictEqual(msg.data, 65);
done();
Expand All @@ -82,6 +84,7 @@ describe('Rclnodejs message type testing', function () {
'Byte_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.deepStrictEqual(msg.data, 10);
done();
Expand Down Expand Up @@ -122,6 +125,7 @@ describe('Rclnodejs message type testing', function () {
'Int8_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.deepStrictEqual(msg.data, 127);
done();
Expand All @@ -142,6 +146,7 @@ describe('Rclnodejs message type testing', function () {
'UInt8_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.deepStrictEqual(msg.data, 255);
done();
Expand All @@ -162,6 +167,7 @@ describe('Rclnodejs message type testing', function () {
'Int16_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.deepStrictEqual(msg.data, 0x7fff);
done();
Expand All @@ -182,6 +188,7 @@ describe('Rclnodejs message type testing', function () {
'UInt16_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.deepStrictEqual(msg.data, 0xffff);
done();
Expand All @@ -202,6 +209,7 @@ describe('Rclnodejs message type testing', function () {
'Int32_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.deepStrictEqual(msg.data, 0x7fffffff);
done();
Expand All @@ -222,6 +230,7 @@ describe('Rclnodejs message type testing', function () {
'UInt32_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.deepStrictEqual(msg.data, 0xffffffff);
done();
Expand All @@ -242,6 +251,7 @@ describe('Rclnodejs message type testing', function () {
'Int64_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'bigint');
assert.deepStrictEqual(msg.data, BigInt('0x1fffffffffffff'));
done();
Expand All @@ -262,6 +272,7 @@ describe('Rclnodejs message type testing', function () {
'UInt64_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'bigint');
assert.deepStrictEqual(msg.data, BigInt('0x1fffffffffffff'));
done();
Expand All @@ -282,6 +293,7 @@ describe('Rclnodejs message type testing', function () {
'Float32_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.ok(Math.abs(msg.data - 3.14) < 0.000001);
done();
Expand All @@ -302,6 +314,7 @@ describe('Rclnodejs message type testing', function () {
'Float64_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.deepStrictEqual(typeof msg.data, 'number');
assert.ok(Math.abs(msg.data - 3.14) < 0.000001);
done();
Expand All @@ -324,6 +337,7 @@ describe('Rclnodejs message type testing', function () {
'ColorRGBA_channel',
(msg) => {
publisher.kill('SIGINT');
node.destroySubscription(subscription);
assert.ok('r' in msg);
assert.deepStrictEqual(typeof msg.r, 'number');
assert.deepStrictEqual(msg.r, 127);
Expand Down Expand Up @@ -351,7 +365,7 @@ describe('Rclnodejs message type testing', function () {
'Header_channel',
(header) => {
publisher.kill('SIGINT');

node.destroySubscription(subscription);
assert.ok('stamp' in header);
assert.ok('sec' in header.stamp);
assert.deepStrictEqual(header.stamp.sec, 123456);
Expand All @@ -377,7 +391,7 @@ describe('Rclnodejs message type testing', function () {
'JointState_channel',
(state) => {
publisher.kill('SIGINT');

node.destroySubscription(subscription);
assert.deepStrictEqual(state.name, ['Tom', 'Jerry']);
assert.deepStrictEqual(state.position, Float64Array.from([1, 2]));
assert.deepStrictEqual(state.velocity, Float64Array.from([2, 3]));
Expand Down
Loading