/**
 * TEAM: frontend_infra
 * @flow
 */

// TODO: Fix this eslint issue on next edit. This is an autogenerated comment.
// eslint-disable-next-line flexport/no-legacy-dependencies
import {mount, shallow} from "enzyme";
import Loader from "../Loader";

function shallowLoader(propOverrides: {...} = {}) {
  const defaultProps = {loaded: false};
  // $FlowFixMe[cannot-spread-inexact] upgrade 0.110.1 -> 0.111.1
  const mergedProps = {...defaultProps, ...propOverrides};
  return shallow(<Loader {...mergedProps} />);
}

const testChild = "Hi, test.";

describe("Loader", () => {
  describe("it does the bare minimum", () => {
    it("matches snapshot", () => {
      const loader = mount(<Loader loaded={false} />);
      expect(loader).toMatchSnapshot();
    });
    it("Renders children if loaded", () => {
      const comp = shallowLoader({loaded: true, children: testChild});
      expect(comp.html()).toContain(testChild);
    });
  });
});
