UNPKG

@tamagui/react-native-web-lite

Version:
103 lines (102 loc) 4.43 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 ".."; 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: !0 })); expect(container.firstChild).toMatchSnapshot(); }), test('is "false"', () => { const { container } = render(/* @__PURE__ */ jsx(ActivityIndicator, { animating: !1 })); expect(container.firstChild).toMatchSnapshot(); }); }), test('prop "color"', () => { const { container } = render(/* @__PURE__ */ jsx(ActivityIndicator, { color: "red" })), 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: !1, hidesWhenStopped: !0 }) ); expect(container.firstChild).toMatchSnapshot(); }), test('is "false"', () => { const { container } = render( /* @__PURE__ */ jsx(ActivityIndicator, { animating: !1, hidesWhenStopped: !1 }) ); 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(), ref = React.createRef(); act(() => { render(/* @__PURE__ */ jsx(ActivityIndicator, { onBlur, ref })); }); const target = createEventTarget(ref.current), 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(), 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.js.map