@@ -8,10 +8,7 @@ vi.mock('../../gen/service/motion/v1/motion_pb_service');
8
8
vi . mock ( '../../robot' ) ;
9
9
10
10
import { Struct , Timestamp } from '@bufbuild/protobuf' ;
11
- import {
12
- createPromiseClient ,
13
- createRouterTransport ,
14
- } from '@connectrpc/connect' ;
11
+ import { createClient , createRouterTransport } from '@connectrpc/connect' ;
15
12
import { MotionService } from '../../gen/service/motion/v1/motion_connect' ;
16
13
import {
17
14
GetPlanRequest ,
@@ -21,16 +18,23 @@ import {
21
18
MoveRequest ,
22
19
StopPlanRequest ,
23
20
} from '../../gen/service/motion/v1/motion_pb' ;
24
- import { GeoGeometry , GeoPoint , Pose , PoseInFrame , ResourceName } from '../../types' ;
21
+ import {
22
+ GeoGeometry ,
23
+ GeoPoint ,
24
+ Pose ,
25
+ PoseInFrame ,
26
+ ResourceName ,
27
+ } from '../../types' ;
25
28
import { MotionClient } from './client' ;
26
29
import {
30
+ Constraints ,
27
31
GetPlanResponse ,
28
32
ListPlanStatusesResponse ,
29
33
MotionConfiguration ,
30
34
ObstacleDetector ,
31
35
PlanState ,
36
+ PseudolinearConstraint ,
32
37
} from './types' ;
33
- import { Constraints , PseudolinearConstraint } from './types' ;
34
38
35
39
const motionClientName = 'test-motion' ;
36
40
const date = new Date ( 1970 , 1 , 1 , 1 , 1 , 1 ) ;
@@ -78,9 +82,7 @@ describe('moveOnGlobe', () => {
78
82
79
83
RobotClient . prototype . createServiceClient = vi
80
84
. fn ( )
81
- . mockImplementation ( ( ) =>
82
- createPromiseClient ( MotionService , mockTransport )
83
- ) ;
85
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
84
86
85
87
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
86
88
@@ -228,9 +230,7 @@ describe('moveOnGlobe', () => {
228
230
229
231
RobotClient . prototype . createServiceClient = vi
230
232
. fn ( )
231
- . mockImplementation ( ( ) =>
232
- createPromiseClient ( MotionService , mockTransport )
233
- ) ;
233
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
234
234
235
235
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
236
236
@@ -273,25 +273,25 @@ describe('move', () => {
273
273
subtype : 'base' ,
274
274
name : 'myBase' ,
275
275
} ) ;
276
- const expectedDestination : PoseInFrame = {
276
+ const expectedDestination = new PoseInFrame ( {
277
277
referenceFrame : 'world' ,
278
- pose : {
278
+ pose : new Pose ( {
279
279
x : 1 ,
280
280
y : 2 ,
281
281
z : 3 ,
282
282
oX : 0 ,
283
283
oY : 0 ,
284
284
oZ : 1 ,
285
285
theta : 90 ,
286
- } ,
287
- } ;
286
+ } ) ,
287
+ } ) ;
288
288
const expectedPseudolinearConstraint = new PseudolinearConstraint ( {
289
- lineToleranceFactor : 0. 5,
290
- orientationToleranceFactor : 0.1 ,
289
+ lineToleranceFactor : 5 ,
290
+ orientationToleranceFactor : 10 ,
291
291
} ) ;
292
- const expectedConstraints : Constraints = {
292
+ const expectedConstraints = new Constraints ( {
293
293
pseudolinearConstraint : [ expectedPseudolinearConstraint ] ,
294
- } ;
294
+ } ) ;
295
295
const expectedExtra = { some : 'extra' } ;
296
296
let capturedReq : MoveRequest | undefined ;
297
297
const mockTransport = createRouterTransport ( ( { service } ) => {
@@ -304,15 +304,13 @@ describe('move', () => {
304
304
} ) ;
305
305
RobotClient . prototype . createServiceClient = vi
306
306
. fn ( )
307
- . mockImplementation ( ( ) =>
308
- createPromiseClient ( MotionService , mockTransport )
309
- ) ;
307
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
310
308
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
311
309
await expect (
312
310
motion . move (
313
311
expectedDestination ,
314
312
expectedComponentName ,
315
- undefined , // worldState
313
+ undefined ,
316
314
expectedConstraints ,
317
315
expectedExtra
318
316
)
@@ -347,9 +345,7 @@ describe('stopPlan', () => {
347
345
348
346
RobotClient . prototype . createServiceClient = vi
349
347
. fn ( )
350
- . mockImplementation ( ( ) =>
351
- createPromiseClient ( MotionService , mockTransport )
352
- ) ;
348
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
353
349
354
350
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
355
351
@@ -380,9 +376,7 @@ describe('stopPlan', () => {
380
376
381
377
RobotClient . prototype . createServiceClient = vi
382
378
. fn ( )
383
- . mockImplementation ( ( ) =>
384
- createPromiseClient ( MotionService , mockTransport )
385
- ) ;
379
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
386
380
387
381
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
388
382
@@ -455,9 +449,7 @@ describe('getPlan', () => {
455
449
456
450
RobotClient . prototype . createServiceClient = vi
457
451
. fn ( )
458
- . mockImplementation ( ( ) =>
459
- createPromiseClient ( MotionService , mockTransport )
460
- ) ;
452
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
461
453
462
454
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
463
455
@@ -492,9 +484,7 @@ describe('getPlan', () => {
492
484
493
485
RobotClient . prototype . createServiceClient = vi
494
486
. fn ( )
495
- . mockImplementation ( ( ) =>
496
- createPromiseClient ( MotionService , mockTransport )
497
- ) ;
487
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
498
488
499
489
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
500
490
@@ -547,9 +537,7 @@ describe('listPlanStatuses', () => {
547
537
548
538
RobotClient . prototype . createServiceClient = vi
549
539
. fn ( )
550
- . mockImplementation ( ( ) =>
551
- createPromiseClient ( MotionService , mockTransport )
552
- ) ;
540
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
553
541
554
542
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
555
543
@@ -575,9 +563,7 @@ describe('listPlanStatuses', () => {
575
563
576
564
RobotClient . prototype . createServiceClient = vi
577
565
. fn ( )
578
- . mockImplementation ( ( ) =>
579
- createPromiseClient ( MotionService , mockTransport )
580
- ) ;
566
+ . mockImplementation ( ( ) => createClient ( MotionService , mockTransport ) ) ;
581
567
582
568
motion = new MotionClient ( new RobotClient ( 'host' ) , motionClientName ) ;
583
569
@@ -587,4 +573,4 @@ describe('listPlanStatuses', () => {
587
573
expect ( capturedReq ?. onlyActivePlans ) . toStrictEqual ( expectedOnlyActivePlans ) ;
588
574
expect ( capturedReq ?. extra ) . toStrictEqual ( Struct . fromJson ( expectedExtra ) ) ;
589
575
} ) ;
590
- } ) ;
576
+ } ) ;
0 commit comments