<commit_before>/* eslint-disable max-len */
import React from "react";
import Immutable from "immutable";
import { Provider } from "react-redux";
import { shallow, mount } from "enzyme";

import { displayOrder, transforms } from "@nteract/transforms";
import Cell from "../../src/components/cell/cell";
import { Notebook, getLanguageMode } from "../../src/components/notebook";

import { dummyStore, dummyCommutable } from "../../src/dummy";

const dummyCellStatuses = dummyCommutable
  .get("cellOrder")
  .reduce(
    (statuses, cellID) =>
      statuses.set(
        cellID,
        Immutable.fromJS({ outputHidden: false, inputHidden: false })
      ),
    new Immutable.Map()
  );

// Boilerplate test to make sure the testing setup is configured
describe("Notebook", () => {
  test("accepts an Immutable.List of cells", () => {
    const component = shallow(
      <Notebook
        notebook={dummyCommutable}
        transient={new Immutable.Map({ cellMap: new Immutable.Map() })}
        cellPagers={new Immutable.Map()}
        cellStatuses={new Immutable.Map()}
        stickyCells={new Immutable.Map()
          // Sticky the first cell of the notebook so that the sticky code gets
          // triggered.
          .set(dummyCommutable.getIn(["cellOrder", 0]), true)}
        CellComponent={Cell}
      />
    );
    expect(component).not.toBeNull();
  });
  test("implements the correct css spec", () => {
    const component = mount(
      <Provider store={dummyStore()}>
        <Notebook
          notebook={dummyCommutable}
          transient={
            new Immutable.Map({
              cellMap: new Immutable.Map()
            })
          }
          cellPagers={new Immutable.Map()}
          cellStatuses={dummyCellStatuses}
          stickyCells={new Immutable.Map()}
          displayOrder={displayOrder}
          transforms={transforms}
          CellComponent={Cell}
          models={new Immutable.Map({})}
        />
      </Provider>
    );
    expect(component.find(".notebook").length).toBeGreaterThan(0);
    expect(component.find(".notebook .cell").length).toBeGreaterThan(0);
    expect(component.find(".notebook .cell.text").length).toBeGreaterThan(0);
    expect(component.find(".notebook .cell.code").length).toBeGreaterThan(0);
    expect(component.find(".notebook .cell.unknown").length).toBe(0);
    expect(
      component.find(".notebook .cell.text .rendered").length
    ).toBeGreaterThan(0);
    expect(
      component.find(".notebook .cell.code .input-container").length
    ).toBeGreaterThan(0);
    expect(
      component.find(".notebook .cell.code .input-container .prompt").length
    ).toBeGreaterThan(0);
    expect(
      component.find(".notebook .cell.code .input-container .input").length
    ).toBeGreaterThan(0);
    expect(
      component.find(".notebook .cell.code .outputs").length
    ).toBeGreaterThan(0);
  });

  describe("getLanguageMode", () => {
    test("determines the right language from the notebook metadata", () => {
      const lang = getLanguageMode(dummyCommutable);
      expect(lang).toBe("ipython");

      const lang2 = getLanguageMode(
        dummyCommutable.setIn(
          ["metadata", "language_info", "codemirror_mode", "name"],
          "r"
        )
      );
      expect(lang2).toBe("r");
    });
  });

  describe("keyDown", () => {
    test("detects a cell execution keypress", () => {
      const focusedCell = dummyCommutable.getIn(["cellOrder", 1]);

      const context = { store: dummyStore() };

      context.store.dispatch = jest.fn();

      const component = shallow(
        <Notebook
          notebook={dummyCommutable}
          transient={new Immutable.Map({ cellMap: new Immutable.Map() })}
          cellPagers={new Immutable.Map()}<commit_msg>remove test for DOM structure of the notebook<commit_after>/* eslint-disable max-len */
import React from "react";
import Immutable from "immutable";
import { Provider } from "react-redux";
import { shallow, mount } from "enzyme";

import { displayOrder, transforms } from "@nteract/transforms";
import Cell from "../../src/components/cell/cell";
import { Notebook, getLanguageMode } from "../../src/components/notebook";

import { dummyStore, dummyCommutable } from "../../src/dummy";

const dummyCellStatuses = dummyCommutable
  .get("cellOrder")
  .reduce(
    (statuses, cellID) =>
      statuses.set(
        cellID,
        Immutable.fromJS({ outputHidden: false, inputHidden: false })
      ),
    new Immutable.Map()
  );

// Boilerplate test to make sure the testing setup is configured
describe("Notebook", () => {
  test("accepts an Immutable.List of cells", () => {
    const component = shallow(
      <Notebook
        notebook={dummyCommutable}
        transient={new Immutable.Map({ cellMap: new Immutable.Map() })}
        cellPagers={new Immutable.Map()}
        cellStatuses={new Immutable.Map()}
        stickyCells={new Immutable.Map()
          // Sticky the first cell of the notebook so that the sticky code gets
          // triggered.
          .set(dummyCommutable.getIn(["cellOrder", 0]), true)}
        CellComponent={Cell}
      />
    );
    expect(component).not.toBeNull();
  });

  describe("getLanguageMode", () => {
    test("determines the right language from the notebook metadata", () => {
      const lang = getLanguageMode(dummyCommutable);
      expect(lang).toBe("ipython");

      const lang2 = getLanguageMode(
        dummyCommutable.setIn(
          ["metadata", "language_info", "codemirror_mode", "name"],
          "r"
        )
      );
      expect(lang2).toBe("r");
    });
  });

  describe("keyDown", () => {
    test("detects a cell execution keypress", () => {
      const focusedCell = dummyCommutable.getIn(["cellOrder", 1]);

      const context = { store: dummyStore() };

      context.store.dispatch = jest.fn();

      const component = shallow(
        <Notebook
          notebook={dummyCommutable}
          transient={new Immutable.Map({ cellMap: new Immutable.Map() })}
          cellPagers={new Immutable.Map()}
{'fraction_non_alphanumeric': 0.14744332285288764, 'fraction_numerical': 0.002978652986927023, 'mean_word_length': 2.8253164556962025, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5006624', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1736, 'n_words': 385}