<commit_before>import NotesWidget from '../../src/components/notes';
import { Factory, FactoryBot } from '../helpers';
import Router from '../../src/helpers/router';

jest.mock('../../src/models/user', () => ({
  notesUX: {
    statusMessage: {
      display: false,
    },
    hideSummary: jest.fn(),
    isSummaryVisible: true,
  },
}));
jest.mock('../../src/helpers/router');
jest.mock('../../../shared/src/components/html', () => ({ html }) =>
  html ? <div dangerouslySetInnerHTML={{ __html: html }} /> : null
);

describe('Notes', () => {

  let props;

  beforeEach(function() {
    const course = Factory.course();
    const chapter = 1;
    const section = 1;
    course.referenceBook.update(FactoryBot.create('Book'));
    const page = course.referenceBook.pages.byChapterSection.get(`${chapter}.${section}`);

    Router.currentQuery.mockReturnValue({});
    const body = window.document.body;
    const notes = Factory.notesPageMap({
      course, chapter, section,
    });
    body.innerHTML = '<div id="mount"><div class="book-content">' +
      page.content_html
        .replace(/^[\s\S]*<body[\s\S]*?>/, '')
        .replace(/<\/body>[\s\S]*$/, '') + '</div></div>';
    window.getSelection = jest.fn(() => ({
      removeAllRanges: jest.fn(),
      addRange: jest.fn(),
      getRangeAt: jest.fn(() => ({
        cloneRange: jest.fn(),
        getBoundingClientRect: jest.fn(() => ({
          bottom: 150,
          top: 100,
          left: 100,
          right: 150,
        })),
      })),
    }));
    window.document.createRange = jest.fn(() => ({
      setStart: jest.fn(),
      setEnd: jest.fn(),
      collapse: jest.fn(),
    }));
    props = {
      page,
      notes,
      course,
      windowImpl: window,<commit_msg>contents does the regex cleaning<commit_after>import NotesWidget from '../../src/components/notes';
import { Factory, FactoryBot } from '../helpers';
import Router from '../../src/helpers/router';

jest.mock('../../src/models/user', () => ({
  notesUX: {
    statusMessage: {
      display: false,
    },
    hideSummary: jest.fn(),
    isSummaryVisible: true,
  },
}));
jest.mock('../../src/helpers/router');
jest.mock('../../../shared/src/components/html', () => ({ html }) =>
  html ? <div dangerouslySetInnerHTML={{ __html: html }} /> : null
);

describe('Notes', () => {

  let props;

  beforeEach(function() {
    const course = Factory.course();
    const chapter = 1;
    const section = 1;
    course.referenceBook.update(FactoryBot.create('Book'));
    const page = course.referenceBook.pages.byChapterSection.get(`${chapter}.${section}`);

    Router.currentQuery.mockReturnValue({});
    const body = window.document.body;
    const notes = Factory.notesPageMap({
      course, chapter, section,
    });
    body.innerHTML = '<div id="mount"><div class="book-content">' +
      page.contents;
    window.getSelection = jest.fn(() => ({
      removeAllRanges: jest.fn(),
      addRange: jest.fn(),
      getRangeAt: jest.fn(() => ({
        cloneRange: jest.fn(),
        getBoundingClientRect: jest.fn(() => ({
          bottom: 150,
          top: 100,
          left: 100,
          right: 150,
        })),
      })),
    }));
    window.document.createRange = jest.fn(() => ({
      setStart: jest.fn(),
      setEnd: jest.fn(),
      collapse: jest.fn(),
    }));
    props = {
      page,
      notes,
      course,
      windowImpl: window,
{'fraction_non_alphanumeric': 0.2002932551319648, 'fraction_numerical': 0.008211143695014663, 'mean_word_length': 2.4984615384615383, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, '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': '7470305', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1041, 'n_words': 200}