<commit_before>const SandboxedModule = require('sandboxed-module')
require('chai').should()
const sinon = require('sinon')
const modulePath = require('path').join(
  __dirname,
  '../../../../app/src/Features/Spelling/SpellingController.js'
)

const TEN_SECONDS = 1000 * 10

const SPELLING_HOST = 'http://spelling.service.test'
const SPELLING_URL = 'http://spelling.service.test'

describe('SpellingController', function() {
  const userId = '1<PASSWORD>'

  beforeEach(function() {
    this.requestStreamPipe = sinon.stub()
    this.requestStreamOn = sinon
      .stub()
      .returns({ pipe: this.requestStreamPipe })
    this.request = sinon.stub().returns({
      on: this.requestStreamOn
    })

    this.AuthenticationController = {
      getLoggedInUserId: req => req.session.user._id
    }
    this.controller = SandboxedModule.require(modulePath, {
      requires: {
        request: this.request,
        'logger-sharelatex': {
          warn() {},
          err() {}
        },
        'settings-sharelatex': {
          languages: [
            { name: 'English', code: 'en' },
            { name: 'French', code: 'fr' }
          ],
          apis: { spelling: { host: SPELLING_HOST, url: SPELLING_URL } }
        },
        '../Authentication/AuthenticationController': this
          .AuthenticationController
      }
    })
    this.req = {
      url: '/spelling/check',
      method: 'POST',
      params: {},
      session: {
        user: {
          _id: userId
        }
      },
      headers: { Host: SPELLING_HOST }<commit_msg>added stub for log.info<commit_after>const SandboxedModule = require('sandboxed-module')
require('chai').should()
const sinon = require('sinon')
const modulePath = require('path').join(
  __dirname,
  '../../../../app/src/Features/Spelling/SpellingController.js'
)

const TEN_SECONDS = 1000 * 10

const SPELLING_HOST = 'http://spelling.service.test'
const SPELLING_URL = 'http://spelling.service.test'

describe('SpellingController', function() {
  const userId = '1<PASSWORD>'

  beforeEach(function() {
    this.requestStreamPipe = sinon.stub()
    this.requestStreamOn = sinon
      .stub()
      .returns({ pipe: this.requestStreamPipe })
    this.request = sinon.stub().returns({
      on: this.requestStreamOn
    })

    this.AuthenticationController = {
      getLoggedInUserId: req => req.session.user._id
    }
    this.controller = SandboxedModule.require(modulePath, {
      requires: {
        request: this.request,
        'logger-sharelatex': {
          warn() {},
          err() {},
          info() {}
        },
        'settings-sharelatex': {
          languages: [
            { name: 'English', code: 'en' },
            { name: 'French', code: 'fr' }
          ],
          apis: { spelling: { host: SPELLING_HOST, url: SPELLING_URL } }
        },
        '../Authentication/AuthenticationController': this
          .AuthenticationController
      }
    })
    this.req = {
      url: '/spelling/check',
      method: 'POST',
      params: {},
      session: {
        user: {
          _id: userId
        }
      },
      headers: { Host: SPELLING_HOST }
{'fraction_non_alphanumeric': 0.14736842105263157, 'fraction_numerical': 0.004465709728867623, 'mean_word_length': 2.2975814931650893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5450491', 'n_tokens_mistral': 965, 'n_tokens_neox': 956, 'n_words': 172}