Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Dec 13, 2024
1 parent 8c96b57 commit e5dcda6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useState, useRef, useCallback, useEffect } from 'react'
import styled from 'styled-components'
import {
Box,
DIRECTION_COLUMN,
DISPLAY_FLEX,
Flex,
JUSTIFY_SPACE_BETWEEN,
Box,
} from '@opentrons/components'
import { TimelineToolbox } from './Timeline/TimelineToolbox'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { describe, it, vi, beforeEach } from 'vitest'
import { screen } from '@testing-library/react'

import { i18n } from '../../../../assets/localization'
import { renderWithProviders } from '../../../../__testing-utils__'
import { TimelineToolbox } from '../Timeline'
import { DraggableSidebar } from '../DraggableSidebar'

import type { ComponentProps } from 'react'

vi.mock('../Timeline')
vi.mock('../../../../step-forms/selectors')
vi.mock('../../../../ui/steps/selectors')
// vi.mock('../Timeline', async importOriginal => {
// const actual = await importOriginal<typeof TimelineToolbox>()
// return {
// ...actual,
// TimelineToolbox: () => <div>mock TimelineToolbox</div>,
// }
// })

const mockSetTargetWidth = vi.fn()

const render = (props: ComponentProps<typeof DraggableSidebar>) => {
return renderWithProviders(<DraggableSidebar {...props} />, {
i18nInstance: i18n,
})
}

describe('DraggableSidebar', () => {
let props: ComponentProps<typeof DraggableSidebar>
beforeEach(() => {
props = {
setTargetWidth: mockSetTargetWidth,
}
vi.mocked(TimelineToolbox).mockReturnValue(<div>mock TimelineToolbox</div>)
})

it('renders mock TimelineToolbox', () => {
render(props)
screen.getByText('mock TimelineToolbox')
})
})

0 comments on commit e5dcda6

Please sign in to comment.