<commit_before>import { expect } from 'chai';

import * as commutable from 'commutable';

import {
  loadNotebook,
  updateExecutionCount,
  newCellAfter,
} from '../../src/reducers/document';

import {
  dummyJSON,
  dummyCommutable,
} from '../dummy-nb';

describe('loadNotebook', () => {
  it('converts a JSON notebook to our commutable notebook and puts in state', () => {
    const state = loadNotebook({}, { data: dummyJSON });
    expect(state.notebook.get('nbformat')).to.equal(4);
  });
});

describe('updateExecutionCount', () => {
  it('updates the execution count by id', () => {
    const originalState = {
      notebook: commutable.appendCell(dummyCommutable, commutable.emptyCodeCell),
    };

    const id = originalState.notebook.get('cellOrder').last();

    const action = {
      id,
      count: 42,
    };

    const state = updateExecutionCount(originalState, action);
    expect(state.notebook.getIn(['cellMap', id, 'execution_count'])).to.equal(42);
  });
});

describe('newCellAfter', () => {
  it('creates a brand new cell after the given id', () => {
    const originalState = {
      notebook: commutable.appendCell(dummyCommutable, commutable.emptyCodeCell),
    };
    const id = originalState.notebook.get('cellOrder').last();

    const action = {
      id,
      cellType: 'markdown',
    };

    const state = newCellAfter(originalState, action);
    expect(state.notebook.get('cellOrder').size).to.equal(3);
    const cell = state.notebook.get('cellOrder').last();
    expect(state.notebook.getIn(['cellMap', id, 'execution_count'])).to.equal(42);
  });
});
<commit_msg>There are now 4 cells in the test.<commit_after>import { expect } from 'chai';

import * as commutable from 'commutable';

import {
  loadNotebook,
  updateExecutionCount,
  newCellAfter,
} from '../../src/reducers/document';

import {
  dummyJSON,
  dummyCommutable,
} from '../dummy-nb';

describe('loadNotebook', () => {
  it('converts a JSON notebook to our commutable notebook and puts in state', () => {
    const state = loadNotebook({}, { data: dummyJSON });
    expect(state.notebook.get('nbformat')).to.equal(4);
  });
});

describe('updateExecutionCount', () => {
  it('updates the execution count by id', () => {
    const originalState = {
      notebook: commutable.appendCell(dummyCommutable, commutable.emptyCodeCell),
    };

    const id = originalState.notebook.get('cellOrder').last();

    const action = {
      id,
      count: 42,
    };

    const state = updateExecutionCount(originalState, action);
    expect(state.notebook.getIn(['cellMap', id, 'execution_count'])).to.equal(42);
  });
});

describe('newCellAfter', () => {
  it('creates a brand new cell after the given id', () => {
    const originalState = {
      notebook: commutable.appendCell(dummyCommutable, commutable.emptyCodeCell),
    };
    const id = originalState.notebook.get('cellOrder').last();

    const action = {
      id,
      cellType: 'markdown',
    };

    const state = newCellAfter(originalState, action);
    expect(state.notebook.get('cellOrder').size).to.equal(4);
    const cell = state.notebook.get('cellOrder').last();
    expect(state.notebook.getIn(['cellMap', id, 'execution_count'])).to.equal(42);
  });
});

{'fraction_non_alphanumeric': 0.16537867078825347, 'fraction_numerical': 0.005255023183925811, 'mean_word_length': 3.779911373707533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2738431', 'n_tokens_mistral': 1019, 'n_tokens_neox': 997, 'n_words': 207}