All files / src/components/SearchBox index.stories.tsx

50% Statements 5/10
100% Branches 0/0
33.33% Functions 1/3
44.44% Lines 4/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                          2x   1x   1x 1x                                
import React from "react";
import { ComponentStory, ComponentMeta } from "@storybook/react";
import { within, userEvent, waitFor } from "@storybook/testing-library";
import { expect } from "@storybook/jest";
 
import SearchBox from "./index";
 
export default {
  title: "Components/SearchBox",
  component: SearchBox,
  parameters: {
    backgrounds: {
      default: "green",
      values: [{ name: "green", value: "#d5ffd7" }],
    },
    viewport: {
      defaultViewport: "tablet",
    },
  },
} as ComponentMeta<typeof SearchBox>;
 
const Template: ComponentStory<typeof SearchBox> = () => <SearchBox />;
 
export const EmptySearchBox = Template.bind({});
 
export const FilledSearchBox = Template.bind({});
FilledSearchBox.play = async ({ canvasElement }) => {
  // Starts querying the component from its root element
  const canvas = within(canvasElement);
 
  await userEvent.type(
    canvas.getByTestId("algolia-search-input"),
    "Renovateの作るPRでArtifact update problemが出た時の対処法",
    {
      delay: 100,
    }
  );
  await waitFor(() => {
    const items = canvas.getByRole("listbox");
    expect(items).toBeInTheDocument();
  });
};