-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
178 additions
and
7 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
step-generation/src/__tests__/absorbanceReaderCloseLid.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { beforeEach, describe, it, expect, vi } from 'vitest' | ||
import { | ||
ABSORBANCE_READER_TYPE, | ||
ABSORBANCE_READER_V1, | ||
} from '@opentrons/shared-data' | ||
import { | ||
getErrorResult, | ||
makeContext, | ||
getInitialRobotStateStandard, | ||
} from '../fixtures' | ||
import { absorbanceReaderCloseLid } from '../commandCreators/atomic/absorbanceReaderCloseLid' | ||
import { absorbanceReaderStateGetter } from '../robotStateSelectors' | ||
import type { | ||
AbsorbanceReaderState, | ||
InvariantContext, | ||
RobotState, | ||
} from '../types' | ||
|
||
const moduleId = 'absorbanceReaderId' | ||
vi.mock('../robotStateSelectors') | ||
|
||
describe('absorbanceReaderCloseLid', () => { | ||
let invariantContext: InvariantContext | ||
let robotState: RobotState | ||
beforeEach(() => { | ||
invariantContext = makeContext() | ||
invariantContext.moduleEntities[moduleId] = { | ||
id: moduleId, | ||
type: ABSORBANCE_READER_TYPE, | ||
model: ABSORBANCE_READER_V1, | ||
} | ||
robotState = getInitialRobotStateStandard(invariantContext) | ||
robotState.modules[moduleId] = { | ||
slot: 'D3', | ||
moduleState: { | ||
type: ABSORBANCE_READER_TYPE, | ||
initialization: null, | ||
lidOpen: false, | ||
}, | ||
} | ||
vi.mocked(absorbanceReaderStateGetter).mockReturnValue( | ||
{} as AbsorbanceReaderState | ||
) | ||
}) | ||
it.only('creates absorbance reader close lid command', () => { | ||
const module = moduleId | ||
const result = absorbanceReaderCloseLid( | ||
{ | ||
module, | ||
commandCreatorFnName: 'absorbanceReaderCloseLid', | ||
}, | ||
invariantContext, | ||
robotState | ||
) | ||
expect(result).toEqual({ | ||
commands: [ | ||
{ | ||
commandType: 'absorbanceReader/closeLid', | ||
key: expect.any(String), | ||
params: { | ||
moduleId: module, | ||
}, | ||
}, | ||
], | ||
}) | ||
}) | ||
it('creates returns error if bad module state', () => { | ||
const module = moduleId | ||
vi.mocked(absorbanceReaderStateGetter).mockReturnValue(null) | ||
const result = absorbanceReaderCloseLid( | ||
{ | ||
module, | ||
commandCreatorFnName: 'absorbanceReaderCloseLid', | ||
}, | ||
invariantContext, | ||
robotState | ||
) | ||
expect(getErrorResult(result).errors).toHaveLength(1) | ||
expect(getErrorResult(result).errors[0]).toMatchObject({ | ||
type: 'MISSING_MODULE', | ||
}) | ||
}) | ||
}) |
83 changes: 83 additions & 0 deletions
83
step-generation/src/__tests__/absorbanceReaderOpenLid.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { beforeEach, describe, it, expect, vi } from 'vitest' | ||
import { | ||
ABSORBANCE_READER_TYPE, | ||
ABSORBANCE_READER_V1, | ||
} from '@opentrons/shared-data' | ||
import { | ||
getErrorResult, | ||
makeContext, | ||
getInitialRobotStateStandard, | ||
} from '../fixtures' | ||
import { absorbanceReaderOpenLid } from '../commandCreators/atomic/absorbanceReaderOpenLid' | ||
import { absorbanceReaderStateGetter } from '../robotStateSelectors' | ||
import type { | ||
AbsorbanceReaderState, | ||
InvariantContext, | ||
RobotState, | ||
} from '../types' | ||
|
||
const moduleId = 'absorbanceReaderId' | ||
vi.mock('../robotStateSelectors') | ||
|
||
describe('absorbanceReaderOpenLid', () => { | ||
let invariantContext: InvariantContext | ||
let robotState: RobotState | ||
beforeEach(() => { | ||
invariantContext = makeContext() | ||
invariantContext.moduleEntities[moduleId] = { | ||
id: moduleId, | ||
type: ABSORBANCE_READER_TYPE, | ||
model: ABSORBANCE_READER_V1, | ||
} | ||
robotState = getInitialRobotStateStandard(invariantContext) | ||
robotState.modules[moduleId] = { | ||
slot: 'D3', | ||
moduleState: { | ||
type: ABSORBANCE_READER_TYPE, | ||
initialization: null, | ||
lidOpen: false, | ||
}, | ||
} | ||
vi.mocked(absorbanceReaderStateGetter).mockReturnValue( | ||
{} as AbsorbanceReaderState | ||
) | ||
}) | ||
it('creates absorbance reader open lid command', () => { | ||
const module = moduleId | ||
const result = absorbanceReaderOpenLid( | ||
{ | ||
module, | ||
commandCreatorFnName: 'absorbanceReaderOpenLid', | ||
}, | ||
invariantContext, | ||
robotState | ||
) | ||
expect(result).toEqual({ | ||
commands: [ | ||
{ | ||
commandType: 'absorbanceReader/openLid', | ||
key: expect.any(String), | ||
params: { | ||
moduleId: module, | ||
}, | ||
}, | ||
], | ||
}) | ||
}) | ||
it('creates returns error if bad module state', () => { | ||
const module = moduleId | ||
vi.mocked(absorbanceReaderStateGetter).mockReturnValue(null) | ||
const result = absorbanceReaderOpenLid( | ||
{ | ||
module, | ||
commandCreatorFnName: 'absorbanceReaderOpenLid', | ||
}, | ||
invariantContext, | ||
robotState | ||
) | ||
expect(getErrorResult(result).errors).toHaveLength(1) | ||
expect(getErrorResult(result).errors[0]).toMatchObject({ | ||
type: 'MISSING_MODULE', | ||
}) | ||
}) | ||
}) |
7 changes: 5 additions & 2 deletions
7
step-generation/src/commandCreators/atomic/absorbanceReaderCloseLid.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
step-generation/src/commandCreators/atomic/absorbanceReaderOpenLid.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters