Created
January 2, 2022 05:09
-
-
Save ifndefdeadmau5/dad0698c701ba8658893a6ce51b0eddf to your computer and use it in GitHub Desktop.
Curriculum Test
This file contains hidden or 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
import type { ReactElement } from 'react'; | |
import { describe } from '@asdgf/core'; | |
import { assert } from '@asdgf/testing-helpers/uvu/assert/index.js'; | |
import { composeStories, render, screen, waitFor, fireEvent } from 'test/render'; | |
import { StoriesToComposeStories } from 'types/storybook'; | |
import * as stories from './CurriculumTable.stories'; | |
const { DefaultStory } = composeStories(stories) as StoriesToComposeStories<typeof stories>; | |
async function renderWithOptions(story: ReactElement) { | |
const renderResult = await render(story); | |
const getMoreButton = () => screen.queryAllByTestId('more-button')[0] as HTMLElement; | |
const getRowsCount = () => screen.getAllByText('밀당영어 G1 기초문법').length; | |
return { getMoreButton, getRowsCount, ...renderResult }; | |
} | |
describe('CurriculumTable', ({ it }) => { | |
it('should be able to delete item via more menu', async () => { | |
const { getMoreButton, getRowsCount } = await renderWithOptions(<DefaultStory />); | |
await waitFor( | |
() => { | |
assert.ok(getRowsCount()); | |
}, | |
{ timeout: 2000 }, | |
); | |
const initialLength = getRowsCount(); | |
await waitFor(() => fireEvent.click(getMoreButton())); | |
await waitFor(() => fireEvent.click(screen.getByText('커리큘럼 삭제'))); | |
await waitFor( | |
() => { | |
assert.is(initialLength - 1, getRowsCount()); | |
}, | |
{ timeout: 2000 }, | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment