1
1
import { describe , it , expect , vi } from 'vitest'
2
2
import {
3
+ DEFAULT_PIPETTE ,
3
4
getInitialRobotStateStandard ,
4
5
getSuccessResult ,
5
6
makeContext ,
6
7
} from '../fixtures'
7
8
import { dispenseInTrash } from '../commandCreators/compound'
8
9
import type { CutoutId } from '@opentrons/shared-data'
9
10
import type { InvariantContext , RobotState } from '../types'
11
+ import { PROTOCOL_CONTEXT_NAME } from '../utils'
10
12
11
13
vi . mock ( '../getNextRobotStateAndWarnings/dispenseUpdateLiquidState' )
12
14
13
- const mockId = 'mockId'
14
15
const mockCutout : CutoutId = 'cutoutA3'
15
- const invariantContext : InvariantContext = makeContext ( )
16
+ const mockTrashId = 'mockTrashId'
17
+ let invariantContext : InvariantContext = {
18
+ ...makeContext ( ) ,
19
+ additionalEquipmentEntities : {
20
+ [ mockTrashId ] : {
21
+ id : mockTrashId ,
22
+ name : 'trashBin' ,
23
+ pythonName : 'mock_trash_bin_1' ,
24
+ location : mockCutout ,
25
+ } ,
26
+ } ,
27
+ }
16
28
const prevRobotState : RobotState = getInitialRobotStateStandard (
17
29
invariantContext
18
30
)
19
31
20
32
describe ( 'dispenseInTrash' , ( ) => {
21
- it ( 'returns correct commands for dispenseInTrash in trash bin' , ( ) => {
33
+ it ( 'returns correct commands for dispenseInTrash in trash bin for flex ' , ( ) => {
22
34
const result = dispenseInTrash (
23
35
{
24
- pipetteId : mockId ,
36
+ pipetteId : DEFAULT_PIPETTE ,
25
37
flowRate : 10 ,
26
38
volume : 10 ,
27
- trashLocation : mockCutout ,
39
+ trashId : mockTrashId ,
28
40
} ,
29
41
invariantContext ,
30
42
prevRobotState
@@ -34,7 +46,7 @@ describe('dispenseInTrash', () => {
34
46
commandType : 'moveToAddressableArea' ,
35
47
key : expect . any ( String ) ,
36
48
params : {
37
- pipetteId : mockId ,
49
+ pipetteId : DEFAULT_PIPETTE ,
38
50
addressableAreaName : 'movableTrashA3' ,
39
51
offset : { x : 0 , y : 0 , z : 0 } ,
40
52
} ,
@@ -43,11 +55,71 @@ describe('dispenseInTrash', () => {
43
55
commandType : 'dispenseInPlace' ,
44
56
key : expect . any ( String ) ,
45
57
params : {
46
- pipetteId : mockId ,
58
+ pipetteId : DEFAULT_PIPETTE ,
47
59
volume : 10 ,
48
60
flowRate : 10 ,
49
61
} ,
50
62
} ,
51
63
] )
64
+ expect ( getSuccessResult ( result ) . python ) . toBe (
65
+ `
66
+ mockPythonName.dispense(
67
+ volume=10,
68
+ location=mock_trash_bin_1,
69
+ rate=10 / mockPythonName.flow_rate.dispense,
70
+ )` . trimStart ( )
71
+ )
72
+ } )
73
+ it ( 'returns correct commands for dispenseInTrash in trash bin for ot-2' , ( ) => {
74
+ const mockFixedTrashId = 'fixedTrashId'
75
+ invariantContext = {
76
+ ...invariantContext ,
77
+ additionalEquipmentEntities : {
78
+ [ mockFixedTrashId ] : {
79
+ id : mockFixedTrashId ,
80
+ name : 'trashBin' ,
81
+ pythonName : `${ PROTOCOL_CONTEXT_NAME } .fixed_trash` ,
82
+ location : 'cutout12' ,
83
+ } ,
84
+ } ,
85
+ }
86
+ const result = dispenseInTrash (
87
+ {
88
+ pipetteId : DEFAULT_PIPETTE ,
89
+ flowRate : 10 ,
90
+ volume : 10 ,
91
+ trashId : mockFixedTrashId ,
92
+ } ,
93
+ invariantContext ,
94
+ prevRobotState
95
+ )
96
+ expect ( getSuccessResult ( result ) . commands ) . toEqual ( [
97
+ {
98
+ commandType : 'moveToAddressableArea' ,
99
+ key : expect . any ( String ) ,
100
+ params : {
101
+ pipetteId : DEFAULT_PIPETTE ,
102
+ addressableAreaName : 'fixedTrash' ,
103
+ offset : { x : 0 , y : 0 , z : 0 } ,
104
+ } ,
105
+ } ,
106
+ {
107
+ commandType : 'dispenseInPlace' ,
108
+ key : expect . any ( String ) ,
109
+ params : {
110
+ pipetteId : DEFAULT_PIPETTE ,
111
+ volume : 10 ,
112
+ flowRate : 10 ,
113
+ } ,
114
+ } ,
115
+ ] )
116
+ expect ( getSuccessResult ( result ) . python ) . toBe (
117
+ `
118
+ mockPythonName.dispense(
119
+ volume=10,
120
+ location=protocol.fixed_trash,
121
+ rate=10 / mockPythonName.flow_rate.dispense,
122
+ )` . trimStart ( )
123
+ )
52
124
} )
53
125
} )
0 commit comments