-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(app): usb connection and moam modal functionality in module setup #8257
Changes from 1 commit
c6b2b14
eaf9892
fd5e406
1e2f00d
dc80ed7
090ce8d
6441bdb
296ba27
25c156a
472558b
b9b783d
88e4e9b
aa0a4ff
8875e36
522e112
c5e984a
866799b
1d9bfcb
fb91ff7
5daa14c
b8496f5
9e35078
2942f2f
377d8b3
e04e11d
eec117d
d0b08a8
d21e5cc
111e4af
9263ca3
a26d83c
a02cd01
133bde6
2c3581f
a52334c
dc64a67
52696fe
7109e2f
e8334fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import React from 'react' | ||
import '@testing-library/jest-dom' | ||
import { StaticRouter } from 'react-router-dom' | ||
import { ModuleModel, ModuleRealType } from '@opentrons/shared-data' | ||
import { renderWithProviders } from '@opentrons/components/__utils__' | ||
import { i18n } from '../../../../../i18n' | ||
import { ModuleInfo } from '../ModuleInfo' | ||
import { when } from 'jest-when' | ||
|
||
jest.mock('../ModuleInfo') | ||
|
||
const componentPropsMatcher = (matcher: unknown) => | ||
// @ts-expect-error(sa, 2021-08-03): when.allArgs not part of type definition yet for jest-when | ||
when.allArgs((args, equals) => equals(args[0], matcher)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should be able to import this from shared components now if you rebase on top of edge:
|
||
|
||
const render = (props: React.ComponentProps<typeof ModuleInfo>) => { | ||
return renderWithProviders( | ||
<StaticRouter> | ||
<ModuleInfo {...props} /> | ||
</StaticRouter>, | ||
{ | ||
i18nInstance: i18n, | ||
} | ||
) | ||
} | ||
const mockModuleInfo = ModuleInfo as jest.MockedFunction<typeof ModuleInfo> | ||
const MOCK_IS_ATTACHED = false || true | ||
const MOCK_TC_COORDS = [20, 30, 0] | ||
|
||
const STUBBED_ORIENTATION_VALUE = 'left' | ||
const mockTCModule = { | ||
labwareOffset: { x: 3, y: 3, z: 3 }, | ||
moduleId: 'TCModuleId', | ||
model: 'thermocyclerModuleV1' as ModuleModel, | ||
type: 'thermocyclerModuleType' as ModuleRealType, | ||
} | ||
|
||
describe('ModuleInfo', () => { | ||
let props: React.ComponentProps<typeof ModuleInfo> | ||
beforeEach(() => { | ||
props = { | ||
x: 3, | ||
y: 3, | ||
orientation: 'left', | ||
moduleModel: mockTCModule.model, | ||
usbPort: '', | ||
hubPort: '', | ||
isAttached: MOCK_IS_ATTACHED, | ||
} | ||
}) | ||
|
||
it('should render no modules connected', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test isn't actually making any assertion, so it will always pass. what should module info be actually be doing? the test name says it should not render any modules, but i dont think the |
||
const usbPort = null | ||
const hubPort = null | ||
const isAttached = false | ||
props = { | ||
...props, | ||
usbPort, | ||
hubPort, | ||
isAttached, | ||
} | ||
|
||
when(mockModuleInfo) | ||
.calledWith( | ||
componentPropsMatcher({ | ||
orientation: STUBBED_ORIENTATION_VALUE, | ||
moduleModel: mockTCModule.model, | ||
x: MOCK_TC_COORDS[0], | ||
y: MOCK_TC_COORDS[1], | ||
isAttached: true, | ||
usbPort: null, | ||
hubPort: null, | ||
}) | ||
) | ||
.mockReturnValue(<div>mock module info {mockTCModule.model} </div>) | ||
|
||
props = { | ||
...props, | ||
usbPort, | ||
hubPort, | ||
isAttached, | ||
} | ||
}) | ||
|
||
it('should render modules connected on a robot server 4.3 or higher', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same deal here, this test isn't making any assertions |
||
const usbPort = '1' | ||
const hubPort = '1' | ||
const isAttached = true | ||
props = { | ||
...props, | ||
usbPort, | ||
hubPort, | ||
isAttached, | ||
} | ||
|
||
when(mockModuleInfo) | ||
.calledWith( | ||
componentPropsMatcher({ | ||
orientation: STUBBED_ORIENTATION_VALUE, | ||
moduleModel: mockTCModule.model, | ||
x: MOCK_TC_COORDS[0], | ||
y: MOCK_TC_COORDS[1], | ||
isAttached: true, | ||
usbPort: '1', | ||
hubPort: '1', | ||
}) | ||
) | ||
.mockReturnValue(<div>mock module info {mockTCModule.model} </div>) | ||
|
||
props = { | ||
...props, | ||
usbPort, | ||
hubPort, | ||
isAttached, | ||
} | ||
}) | ||
it('should render modules connected on a robot server lower than 4.3', () => { | ||
const usbPort = null | ||
const hubPort = null | ||
const isAttached = true | ||
props = { | ||
...props, | ||
usbPort, | ||
hubPort, | ||
isAttached, | ||
} | ||
|
||
when(mockModuleInfo) | ||
.calledWith( | ||
componentPropsMatcher({ | ||
orientation: STUBBED_ORIENTATION_VALUE, | ||
moduleModel: mockTCModule.model, | ||
x: MOCK_TC_COORDS[0], | ||
y: MOCK_TC_COORDS[1], | ||
isAttached: true, | ||
usbPort: null, | ||
hubPort: null, | ||
}) | ||
) | ||
.mockReturnValue(<div>mock module info {mockTCModule.model} </div>) | ||
|
||
props = { | ||
...props, | ||
usbPort, | ||
hubPort, | ||
isAttached, | ||
} | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test should be testing
ModuleInfo
right? we don't actually want to mock it, we only want to mock the dependencies ofModuleInfo
that we need to