Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Feb 22, 2024
1 parent ced3a61 commit 370054f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
31 changes: 21 additions & 10 deletions app/src/molecules/LegacyModal/__tests__/LegacyModal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import { screen } from '@testing-library/react'

import { COLORS, renderWithProviders } from '@opentrons/components'

Expand All @@ -20,33 +21,43 @@ describe('LegacyModal', () => {
})

it('should render modal without header icon when type is info', () => {
const [{ getByText, queryByTestId, getByTestId }] = render(props)
expect(queryByTestId('Modal_header_icon')).not.toBeInTheDocument()
getByText('mock info modal')
expect(getByTestId('Modal_header')).toHaveStyle(
render(props)
expect(screen.queryByTestId('Modal_header_icon')).not.toBeInTheDocument()
screen.getByText('mock info modal')
expect(screen.getByTestId('Modal_header')).toHaveStyle(
`background-color: ${COLORS.white}`
)
})

it('should render modal with orange header icon when type is warning', () => {
props.type = 'warning'
const [{ getByTestId }] = render(props)
const headerIcon = getByTestId('Modal_header_icon')
render(props)
const headerIcon = screen.getByTestId('Modal_header_icon')
expect(headerIcon).toBeInTheDocument()
expect(headerIcon).toHaveStyle(`color: ${COLORS.yellow50}`)
expect(getByTestId('Modal_header')).toHaveStyle(
expect(screen.getByTestId('Modal_header')).toHaveStyle(
`background-color: ${COLORS.white}`
)
})

it('should render modal with red header icon when type is error', () => {
props.type = 'error'
const [{ getByTestId }] = render(props)
const headerIcon = getByTestId('Modal_header_icon')
render(props)
const headerIcon = screen.getByTestId('Modal_header_icon')
expect(headerIcon).toBeInTheDocument()
expect(headerIcon).toHaveStyle(`color: ${COLORS.red50}`)
expect(getByTestId('Modal_header')).toHaveStyle(
expect(screen.getByTestId('Modal_header')).toHaveStyle(
`background-color: ${COLORS.white}`
)
})

it('should supply a default margin to account for the sidebar, aligning the modal in the center of the app', () => {
render(props)
expect(screen.getByLabelText('ModalShell_ModalArea')).toHaveStyle(
'width: 31.25rem'
)
expect(screen.getByLabelText('ModalShell_ModalArea')).toHaveStyle(
'margin-left: 5.656rem'
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,13 @@ describe('UpdateAppModal', () => {
render(props)
expect(screen.getByTitle('Update Error')).toBeInTheDocument()
})
it('uses a custom width and left margin to properly center the modal', () => {
render(props)
expect(screen.getByLabelText('ModalShell_ModalArea')).toHaveStyle(
'width: 40rem'
)
expect(screen.getByLabelText('ModalShell_ModalArea')).toHaveStyle(
'margin-left: 5.336rem'
)
})
})

0 comments on commit 370054f

Please sign in to comment.