|
| 1 | +import { beforeEach, describe, expect, it, vi } from 'vitest' |
| 2 | + |
| 3 | +import { |
| 4 | + FLEX_STACKER_MODULE_TYPE, |
| 5 | + FLEX_STACKER_MODULE_V1, |
| 6 | +} from '@opentrons/shared-data' |
| 7 | + |
| 8 | +import { flexStackerFill } from '../commandCreators/atomic/flexStackerFill' |
| 9 | +import { getInitialRobotStateStandard, makeContext } from '../fixtures' |
| 10 | + |
| 11 | +import type { InvariantContext, RobotState } from '../types' |
| 12 | + |
| 13 | +const moduleId = 'flexStackerId' |
| 14 | +vi.mock('../robotStateSelectors') |
| 15 | + |
| 16 | +describe('flexStackerStore', () => { |
| 17 | + let invariantContext: InvariantContext |
| 18 | + let robotState: RobotState |
| 19 | + beforeEach(() => { |
| 20 | + invariantContext = makeContext() |
| 21 | + robotState = getInitialRobotStateStandard(invariantContext) |
| 22 | + invariantContext.moduleEntities[moduleId] = { |
| 23 | + id: moduleId, |
| 24 | + type: FLEX_STACKER_MODULE_TYPE, |
| 25 | + model: FLEX_STACKER_MODULE_V1, |
| 26 | + pythonName: 'mock_flex_stacker_1', |
| 27 | + } |
| 28 | + }) |
| 29 | + it('creates flex stacker fill command with count', () => { |
| 30 | + const result = flexStackerFill( |
| 31 | + { |
| 32 | + moduleId, |
| 33 | + count: 10, |
| 34 | + strategy: 'manualWithPause', |
| 35 | + }, |
| 36 | + invariantContext, |
| 37 | + robotState |
| 38 | + ) |
| 39 | + expect(result).toEqual({ |
| 40 | + commands: [ |
| 41 | + { |
| 42 | + commandType: 'flexStacker/fill', |
| 43 | + key: expect.any(String), |
| 44 | + params: { |
| 45 | + moduleId, |
| 46 | + strategy: 'manualWithPause', |
| 47 | + count: 10, |
| 48 | + }, |
| 49 | + }, |
| 50 | + ], |
| 51 | + python: 'mock_flex_stacker_1.fill(count=10)', |
| 52 | + }) |
| 53 | + }) |
| 54 | + it('creates flex stacker fill command with message', () => { |
| 55 | + const result = flexStackerFill( |
| 56 | + { |
| 57 | + moduleId, |
| 58 | + message: 'Filling...', |
| 59 | + strategy: 'manualWithPause', |
| 60 | + }, |
| 61 | + invariantContext, |
| 62 | + robotState |
| 63 | + ) |
| 64 | + expect(result).toEqual({ |
| 65 | + commands: [ |
| 66 | + { |
| 67 | + commandType: 'flexStacker/fill', |
| 68 | + key: expect.any(String), |
| 69 | + params: { |
| 70 | + moduleId, |
| 71 | + strategy: 'manualWithPause', |
| 72 | + message: 'Filling...', |
| 73 | + }, |
| 74 | + }, |
| 75 | + ], |
| 76 | + python: 'mock_flex_stacker_1.fill(message="Filling...")', |
| 77 | + }) |
| 78 | + }) |
| 79 | +}) |
0 commit comments