import React from "react";
import TestRenderer from "react-test-renderer";
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 wrapper = TestRenderer.create(
      <ConfigurationProvider configuration={{ target: "foobar" }}>
        <TestComponent />
      </ConfigurationProvider>
    );

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