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

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

import {
  load,
  newNotebook,
  notebookLoaded,
  extractNewKernel,
  convertRawNotebook,
} from '../../../src/notebook/epics/loading';

import Immutable from 'immutable';

describe('load', () => {
  expect(load('mytest.ipynb')).to.deep.equal({ type: 'LOAD', filename: 'mytest.ipynb' })
})

describe('newNotebook', () => {
  expect(newNotebook('python3', '/tmp'))
    .to.deep.equal({
      type: 'NEW_NOTEBOOK',
      kernelSpecName: 'python3',
      cwd: '/tmp',
    })
})

describe('notebookLoaded', () => {
  expect(notebookLoaded('test', dummyCommutable))
    .to.deep.equal({
      type: 'SET_NOTEBOOK',
      filename: 'test',
      notebook: dummyCommutable,
    })
})

describe('extractNewKernel', () => {
  expect(extractNewKernel('/tmp/test.ipynb', dummyCommutable)).to.deep.equal({
    type: 'LAUNCH_KERNEL',
    kernelSpecName: 'python3',
    cwd: '/tmp',
  })
})

describe('convertRawNotebook', () => {
  const converted = convertRawNotebook({
    filename: '/tmp/test.ipynb',
    data: dummy,
  });
  expect(converted.filename).to.equal('/tmp/test.ipynb');

  const notebook = converted.notebook;
  expect(notebook.get('metadata').toJS())
    .to.deep.equal(dummyCommutable.get('metadata').toJS());
})
<commit_msg>Make test a little bit faster by using immutable<commit_after>import { expect } from 'chai';

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

import {
  load,
  newNotebook,
  notebookLoaded,
  extractNewKernel,
  convertRawNotebook,
} from '../../../src/notebook/epics/loading';

import Immutable from 'immutable';

describe('load', () => {
  expect(load('mytest.ipynb')).to.deep.equal({ type: 'LOAD', filename: 'mytest.ipynb' })
})

describe('newNotebook', () => {
  expect(newNotebook('python3', '/tmp'))
    .to.deep.equal({
      type: 'NEW_NOTEBOOK',
      kernelSpecName: 'python3',
      cwd: '/tmp',
    })
})

describe('notebookLoaded', () => {
  expect(notebookLoaded('test', dummyCommutable))
    .to.deep.equal({
      type: 'SET_NOTEBOOK',
      filename: 'test',
      notebook: dummyCommutable,
    })
})

describe('extractNewKernel', () => {
  expect(extractNewKernel('/tmp/test.ipynb', dummyCommutable)).to.deep.equal({
    type: 'LAUNCH_KERNEL',
    kernelSpecName: 'python3',
    cwd: '/tmp',
  })
})

describe('convertRawNotebook', () => {
  const converted = convertRawNotebook({
    filename: '/tmp/test.ipynb',
    data: dummy,
  });
  expect(converted.filename).to.equal('/tmp/test.ipynb');

  const notebook = converted.notebook;
  expect(dummyCommutable.get('metadata').equals(notebook.get('metadata')))
    .to.be.true;
})

{'fraction_non_alphanumeric': 0.1906701221769715, 'fraction_numerical': 0.0022213994816734544, 'mean_word_length': 3.8422939068100357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3850984', 'n_tokens_mistral': 939, 'n_tokens_neox': 946, 'n_words': 148}