import React from "react";
import { render } from "@testing-library/react-native";
import { View } from "react-native";
import { useConfiguration } from "@applicaster/zapp-react-native-utils/reactHooks/configuration";

import { ConfigurationProvider } from "../ConfigurationProvider";

describe("withConfigurationProvider", () => {
  const TestComponent = () => {
    const configuration = useConfiguration();

    // @ts-ignore
    return <View {...{ configuration }} />;
  };

  it("provides configuration to children", () => {
    const { toJSON } = render(
      <ConfigurationProvider configuration={{ target: "foobar" }}>
        <TestComponent />
      </ConfigurationProvider>
    );

    expect(toJSON()).toMatchSnapshot();
  });
});
