UNPKG

@tamagui/react-native-web-lite

Version:
187 lines (186 loc) 5 kB
import { render } from "@testing-library/react"; import { createEventTarget } from "dom-event-testing-library"; import React from "react"; import { act } from "react-dom/test-utils"; import ActivityIndicator from "../index.mjs"; import { jsx } from "react/jsx-runtime"; describe("components/ActivityIndicator", () => { describe('prop "accessibilityLabel"', () => { test("value is set", () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { accessibilityLabel: "accessibility label" })); expect(container.firstChild).toMatchSnapshot(); }); }); describe('prop "accessibilityLiveRegion"', () => { test("value is set", () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { accessibilityLiveRegion: "polite" })); expect(container.firstChild).toMatchSnapshot(); }); }); describe('prop "animating"', () => { test('is "true"', () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { animating: true })); expect(container.firstChild).toMatchSnapshot(); }); test('is "false"', () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { animating: false })); expect(container.firstChild).toMatchSnapshot(); }); }); test('prop "color"', () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { color: "red" })); const svg = container.firstChild.querySelector("svg"); expect(svg).toMatchSnapshot(); }); describe('prop "dataSet"', () => { test("value is set", () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { dataSet: { one: "one", two: "two" } })); expect(container.firstChild).toMatchSnapshot(); }); }); describe('prop "hidesWhenStopped"', () => { test('is "true"', () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { animating: false, hidesWhenStopped: true })); expect(container.firstChild).toMatchSnapshot(); }); test('is "false"', () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { animating: false, hidesWhenStopped: false })); expect(container.firstChild).toMatchSnapshot(); }); }); describe('prop "nativeID"', () => { test("value is set", () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { nativeID: "123" })); expect(container.firstChild).toMatchSnapshot(); }); }); describe('prop "onBlur"', () => { test("is called", () => { const onBlur = jest.fn(); const ref = React.createRef(); act(() => { render(/* @__PURE__ */jsx(ActivityIndicator, { onBlur, ref })); }); const target = createEventTarget(ref.current); const body = createEventTarget(document.body); act(() => { target.focus(); body.focus({ relatedTarget: target.node }); }); expect(onBlur).toBeCalled(); }); }); describe('prop "onFocus"', () => { test("is called", () => { const onFocus = jest.fn(); const ref = React.createRef(); act(() => { render(/* @__PURE__ */jsx(ActivityIndicator, { onFocus, ref })); }); const target = createEventTarget(ref.current); act(() => { target.focus(); }); expect(onFocus).toBeCalled(); }); }); describe('prop "ref"', () => { test("value is set", () => { const ref = jest.fn(); render(/* @__PURE__ */jsx(ActivityIndicator, { ref })); expect(ref).toBeCalled(); }); }); describe('prop "size"', () => { test('is "large"', () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { size: "large" })); expect(container.firstChild).toMatchSnapshot(); }); test("is a number", () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { size: 30 })); expect(container.firstChild).toMatchSnapshot(); }); }); describe('prop "style"', () => { test("value is set", () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { style: { borderWidth: 5 } })); expect(container.firstChild).toMatchSnapshot(); }); }); describe('prop "testID"', () => { test("value is set", () => { const { container } = render(/* @__PURE__ */jsx(ActivityIndicator, { testID: "123" })); expect(container.firstChild).toMatchSnapshot(); }); }); }); //# sourceMappingURL=index-test.mjs.map