|
1 | 1 | import { describe, it, expect } from 'vitest'
|
2 |
| -import { getSuccessResult } from '../fixtures' |
| 2 | +import { WASTE_CHUTE_CUTOUT } from '@opentrons/shared-data' |
| 3 | +import { |
| 4 | + getSuccessResult, |
| 5 | + makeContext, |
| 6 | + getInitialRobotStateStandard, |
| 7 | + DEFAULT_PIPETTE, |
| 8 | +} from '../fixtures' |
3 | 9 | import { moveToAddressableArea } from '../commandCreators/atomic'
|
| 10 | +import type { InvariantContext, RobotState } from '../types' |
| 11 | +import type { CutoutId } from '@opentrons/shared-data' |
4 | 12 |
|
5 |
| -const getRobotInitialState = (): any => { |
6 |
| - return {} |
7 |
| -} |
8 |
| -const mockId = 'mockId' |
9 |
| -const invariantContext: any = { |
10 |
| - pipetteEntities: { |
11 |
| - [mockId]: { |
12 |
| - name: 'p50_single_flex', |
13 |
| - id: mockId, |
| 13 | +const mockCutout = 'cutoutA3' as CutoutId |
| 14 | +const mockTrashId = 'mockTrashId' |
| 15 | +let invariantContext: InvariantContext = { |
| 16 | + ...makeContext(), |
| 17 | + additionalEquipmentEntities: { |
| 18 | + [mockTrashId]: { |
| 19 | + id: mockTrashId, |
| 20 | + name: 'trashBin', |
| 21 | + pythonName: 'mock_trash_bin_1', |
| 22 | + location: mockCutout, |
14 | 23 | },
|
15 | 24 | },
|
16 | 25 | }
|
| 26 | +const prevRobotState: RobotState = getInitialRobotStateStandard( |
| 27 | + invariantContext |
| 28 | +) |
17 | 29 |
|
18 | 30 | describe('moveToAddressableArea', () => {
|
19 |
| - it('should call moveToAddressableArea with correct params', () => { |
20 |
| - const robotInitialState = getRobotInitialState() |
21 |
| - const mockName = '1ChannelWasteChute' |
| 31 | + it('should call moveToAddressableArea with correct params for trash bin', () => { |
| 32 | + const result = moveToAddressableArea( |
| 33 | + { |
| 34 | + pipetteId: DEFAULT_PIPETTE, |
| 35 | + fixtureId: mockTrashId, |
| 36 | + offset: { x: 0, y: 0, z: 1 }, |
| 37 | + }, |
| 38 | + invariantContext, |
| 39 | + prevRobotState |
| 40 | + ) |
| 41 | + const res = getSuccessResult(result) |
| 42 | + expect(res.commands).toEqual([ |
| 43 | + { |
| 44 | + commandType: 'moveToAddressableArea', |
| 45 | + key: expect.any(String), |
| 46 | + params: { |
| 47 | + pipetteId: DEFAULT_PIPETTE, |
| 48 | + addressableAreaName: 'movableTrashA3', |
| 49 | + offset: { x: 0, y: 0, z: 1 }, |
| 50 | + }, |
| 51 | + }, |
| 52 | + ]) |
| 53 | + expect(getSuccessResult(result).python).toBe( |
| 54 | + 'mockPythonName.move_to(mock_trash_bin_1)' |
| 55 | + ) |
| 56 | + }) |
| 57 | + it('should call moveToAddressableArea with correct params for waste chute', () => { |
| 58 | + const wasteChuteId = 'wasteChuteId' |
| 59 | + invariantContext = { |
| 60 | + ...invariantContext, |
| 61 | + additionalEquipmentEntities: { |
| 62 | + [wasteChuteId]: { |
| 63 | + id: wasteChuteId, |
| 64 | + name: 'wasteChute', |
| 65 | + pythonName: 'mock_waste_chute_1', |
| 66 | + location: WASTE_CHUTE_CUTOUT, |
| 67 | + }, |
| 68 | + }, |
| 69 | + } |
22 | 70 | const result = moveToAddressableArea(
|
23 | 71 | {
|
24 |
| - pipetteId: mockId, |
25 |
| - addressableAreaName: mockName, |
26 |
| - offset: { x: 0, y: 0, z: 0 }, |
| 72 | + pipetteId: DEFAULT_PIPETTE, |
| 73 | + fixtureId: wasteChuteId, |
| 74 | + offset: { x: 0, y: 0, z: 1 }, |
27 | 75 | },
|
28 | 76 | invariantContext,
|
29 |
| - robotInitialState |
| 77 | + prevRobotState |
30 | 78 | )
|
31 | 79 | const res = getSuccessResult(result)
|
32 | 80 | expect(res.commands).toEqual([
|
33 | 81 | {
|
34 | 82 | commandType: 'moveToAddressableArea',
|
35 | 83 | key: expect.any(String),
|
36 | 84 | params: {
|
37 |
| - pipetteId: mockId, |
38 |
| - addressableAreaName: mockName, |
39 |
| - offset: { x: 0, y: 0, z: 0 }, |
| 85 | + pipetteId: DEFAULT_PIPETTE, |
| 86 | + addressableAreaName: '1ChannelWasteChute', |
| 87 | + offset: { x: 0, y: 0, z: 1 }, |
40 | 88 | },
|
41 | 89 | },
|
42 | 90 | ])
|
| 91 | + expect(getSuccessResult(result).python).toBe( |
| 92 | + 'mockPythonName.move_to(mock_waste_chute_1)' |
| 93 | + ) |
43 | 94 | })
|
44 | 95 | })
|
0 commit comments