/**
 * TEAM: frontend_infra
 * WATCHERS: ctan
 *
 * @flow
 */

import * as React from "react";
// TODO: Fix this eslint issue on next edit. This is an autogenerated comment.
// eslint-disable-next-line flexport/no-legacy-dependencies
import {mount} from "enzyme";
import Highlighter from "../Highlighter";

function mountHighlighter(children: React.Node, propOverrides: {...} = {}) {
  return mount(
    // $FlowFixMe[cannot-spread-inexact] upgrade 0.121.1 -> 0.122.0
    <Highlighter
      color="grey20"
      selectionRef={{current: null}}
      {...propOverrides}
    >
      {children}
    </Highlighter>
  );
}

describe("Highlighter", () => {
  it("can render Highlighter correctly", () => {
    const comp = mountHighlighter(<div />);

    expect(comp.length).toEqual(1);
  });
  it("can render children correctly", () => {
    const comp = mountHighlighter(
      <>
        <span />
        <span />
        <span />
      </>
    );
    expect(comp.find("span").length).toEqual(3);
  });
});
