@@ -20,10 +20,6 @@ const assert = require('assert');
2020const rclnodejs = require ( '../index.js' ) ;
2121
2222describe ( 'Testing message files generated from an action file' , function ( ) {
23- // let testRootDir = __dirname;
24- // let testActionDir = path.join(testRootDir, 'ros1_actions');
25- // let pkgRootDir = path.dirname(testRootDir);
26- // let msgGenRootDir = path.join(pkgRootDir, 'generated');
2723
2824 this . timeout ( 60 * 1000 ) ;
2925
@@ -66,6 +62,7 @@ describe('Testing message files generated from an action file', function() {
6662 rclnodejs : rclnodejs
6763 } ) ;
6864 as . on ( 'goal' , function ( goal ) {
65+ clearInterval ( timer ) ;
6966 done ( ) ;
7067 } ) ;
7168 as . start ( ) ;
@@ -76,6 +73,9 @@ describe('Testing message files generated from an action file', function() {
7673 rclnodejs : rclnodejs
7774 } ) ;
7875 ac . sendGoal ( { goal : { dishwasher_id : 4 } } ) ;
76+ let timer = setInterval ( ( ) => {
77+ ac . sendGoal ( { goal : { dishwasher_id : 4 } } ) ;
78+ } , 50 ) ;
7979 } ) ;
8080
8181 it ( 'ActionLib client feedback accepted' , function ( done ) {
@@ -101,9 +101,14 @@ describe('Testing message files generated from an action file', function() {
101101 } ) ;
102102 ac . on ( 'feedback' , function ( feedback ) {
103103 assert . strictEqual ( feedback . percent_complete , 70 ) ;
104+ clearInterval ( timer ) ;
104105 done ( ) ;
105106 } ) ;
107+
106108 ac . sendGoal ( { goal : { dishwasher_id : 5 } } ) ;
109+ let timer = setInterval ( ( ) => {
110+ ac . sendGoal ( { goal : { dishwasher_id : 5 } } ) ;
111+ } , 50 ) ;
107112 } ) ;
108113
109114 it ( 'ActionLib server goal cancelled' , function ( done ) {
@@ -128,9 +133,14 @@ describe('Testing message files generated from an action file', function() {
128133 } , Error ) ;
129134 } ) ;
130135 ac . on ( 'status' , function ( status ) {
136+ clearInterval ( timer ) ;
131137 done ( ) ;
132138 } ) ;
139+
133140 ac . sendGoal ( { goal : { dishwasher_id : 6 } } ) ;
141+ let timer = setInterval ( ( ) => {
142+ ac . sendGoal ( { goal : { dishwasher_id : 6 } } ) ;
143+ } , 50 ) ;
134144 } ) ;
135145
136146 it ( 'ActionLib server goal setCancelled' , function ( done ) {
@@ -141,13 +151,12 @@ describe('Testing message files generated from an action file', function() {
141151 } ) ;
142152 as . on ( 'goal' , function ( goal ) {
143153 goal . setAccepted ( 'goal accepted' ) ;
144-
145- ac . cancel ( goal . id ) ;
146-
147154 as . on ( 'cancel' , function ( goalHandle ) {
148155 goal . setCancelled ( { total_dishes_cleaned : 10 } , 'canceled' ) ;
156+ clearInterval ( timer ) ;
149157 done ( ) ;
150158 } ) ;
159+ ac . cancel ( goal . id ) ;
151160 } ) ;
152161
153162 as . start ( ) ;
@@ -158,6 +167,9 @@ describe('Testing message files generated from an action file', function() {
158167 rclnodejs : rclnodejs
159168 } ) ;
160169 ac . sendGoal ( { goal : { dishwasher_id : 7 } } ) ;
170+ let timer = setInterval ( ( ) => {
171+ ac . sendGoal ( { goal : { dishwasher_id : 7 } } ) ;
172+ } , 50 ) ;
161173 } ) ;
162174
163175 it ( 'ActionLib server goal setRejected' , function ( done ) {
@@ -181,10 +193,14 @@ describe('Testing message files generated from an action file', function() {
181193 ac . on ( 'status' , function ( status ) {
182194 if ( count ++ == 1 ) {
183195 assert . strictEqual ( status . status_list [ 0 ] . text , 'rejected' ) ;
196+ clearInterval ( timer ) ;
184197 done ( ) ;
185198 }
186199 } ) ;
187200 ac . sendGoal ( { goal : { dishwasher_id : 8 } } ) ;
201+ let timer = setInterval ( ( ) => {
202+ ac . sendGoal ( { goal : { dishwasher_id : 8 } } ) ;
203+ } , 50 ) ;
188204 } ) ;
189205
190206 it ( 'ActionLib server goal setAborted' , function ( done ) {
@@ -207,10 +223,13 @@ describe('Testing message files generated from an action file', function() {
207223 } ) ;
208224 ac . on ( 'result' , function ( result ) {
209225 assert . strictEqual ( result . total_dishes_cleaned , 0 ) ;
210-
226+ clearInterval ( timer ) ;
211227 done ( ) ;
212228 } ) ;
213- ac . sendGoal ( { goal : { dishwasher_id : 9 } } ) ;
229+ ac . sendGoal ( { goal : { dishwasher_id : 9 } } ) ;
230+ let timer = setInterval ( ( ) => {
231+ ac . sendGoal ( { goal : { dishwasher_id : 9 } } ) ;
232+ } , 50 ) ;
214233 } ) ;
215234
216235 it ( 'ActionLib sever goal setSucceeded' , function ( done ) {
@@ -232,10 +251,14 @@ describe('Testing message files generated from an action file', function() {
232251 } ) ;
233252 ac . on ( 'result' , function ( result ) {
234253 assert . strictEqual ( result . total_dishes_cleaned , 100 ) ;
254+ clearInterval ( timer ) ;
235255 done ( ) ;
236256 } ) ;
237257
238- ac . sendGoal ( { goal : { dishwasher_id : 9 } } ) ;
258+ ac . sendGoal ( { goal : { dishwasher_id : 10 } } ) ;
259+ let timer = setInterval ( ( ) => {
260+ ac . sendGoal ( { goal : { dishwasher_id : 10 } } ) ;
261+ } , 50 ) ;
239262 } ) ;
240263
241264 it ( 'ActionLib complete process' , function ( done ) {
@@ -265,10 +288,14 @@ describe('Testing message files generated from an action file', function() {
265288 } ) ;
266289 ac . on ( 'result' , function ( result ) {
267290 assert . strictEqual ( result . total_dishes_cleaned , 100 ) ;
291+ clearInterval ( timer ) ;
268292 done ( ) ;
269293 } ) ;
270294
271295 ac . sendGoal ( { goal : { dishwasher_id : 11 } } ) ;
296+ let timer = setInterval ( ( ) => {
297+ ac . sendGoal ( { goal : { dishwasher_id : 11 } } ) ;
298+ } , 50 ) ;
272299 } ) ;
273300
274301 it ( 'ActionClient cancel' , function ( done ) {
@@ -281,7 +308,8 @@ describe('Testing message files generated from an action file', function() {
281308 goal . setAccepted ( 'goal accepted' ) ;
282309 ac . cancel ( gGoal . goal_id . id ) ;
283310 } ) ;
284- as . on ( 'cancel' , function ( goalHandle ) {
311+ as . on ( 'cancel' , function ( goalHandle ) {
312+ clearInterval ( timer ) ;
285313 done ( ) ;
286314 } ) ;
287315 as . start ( ) ;
@@ -291,7 +319,10 @@ describe('Testing message files generated from an action file', function() {
291319 actionServer : 'dishes12' ,
292320 rclnodejs : rclnodejs
293321 } ) ;
294- let gGoal = ac . sendGoal ( { goal : { dishwasher_id : 12 } } ) ;
322+ var gGoal = ac . sendGoal ( { goal : { dishwasher_id : 12 } } ) ;
323+ let timer = setInterval ( ( ) => {
324+ gGoal = ac . sendGoal ( { goal : { dishwasher_id : 12 } } ) ;
325+ } , 50 ) ;
295326 } ) ;
296327
297328 it ( 'ActionClient shutdown' , function ( ) {
@@ -310,7 +341,7 @@ describe('Testing message files generated from an action file', function() {
310341 actionServer : 'dishes13' ,
311342 rclnodejs : rclnodejs
312343 } ) ;
313- ac . sendGoal ( { goal : { dishwasher_id : 12 } } ) ;
344+ ac . sendGoal ( { goal : { dishwasher_id : 13 } } ) ;
314345 ac . shutdown ( ) ;
315346 } ) ;
316347
@@ -337,11 +368,15 @@ describe('Testing message files generated from an action file', function() {
337368 status . status_list . forEach ( ( s ) => {
338369 if ( count ++ == 1 && s . goal_id . id === goal . goal_id . id &&
339370 s . status === GoalStatus . SUCCEEDED ) {
371+ clearInterval ( timer ) ;
340372 done ( ) ;
341373 }
342374 } ) ;
343375 } ) ;
344376
345- let goal = ac . sendGoal ( { goal : { dishwasher_id : 12 } } ) ;
377+ var goal = ac . sendGoal ( { goal : { dishwasher_id : 14 } } ) ;
378+ let timer = setInterval ( ( ) => {
379+ goal = ac . sendGoal ( { goal : { dishwasher_id : 14 } } ) ;
380+ } , 50 ) ;
346381 } ) ;
347382} ) ;
0 commit comments