<commit_before>/* eslint-env mocha */
/* global expect, testContext */
/* eslint-disable prefer-arrow-callback, no-unused-expressions, max-nested-callbacks */
import stubs from 'src/test/stubs'
import factory from 'src/test/factories'
import {resetDB, mockIdmUsersById} from 'src/test/helpers'

describe(testContext(__filename), function () {
  beforeEach(resetDB)
  beforeEach(function () {
    stubs.chatService.enable()
    stubs.jobService.enable()
  })
  afterEach(function () {
    stubs.chatService.disable()
    stubs.jobService.disable()
  })

  describe('processProjectStarted()', async function () {
    const chatService = require('src/server/services/chatService')
    const jobService = require('src/server/services/jobService')
    const {processProjectStarted} = require('../projectStarted')
    beforeEach(async function () {
      this.project = await factory.create('project')
      this.players = await mockIdmUsersById(this.project.playerIds, null, {strict: true, times: 10})
      this.playerHandles = this.players.map(p => p.handle)
    })

    it('send a welcome message to the project members', async function () {
      await processProjectStarted(this.project)
      expect(chatService.sendDirectMessage).to.have.been.calledWithMatch(this.playerHandles, 'Welcome to the')
    })

    it('creates a \'projectArtifactDeadlinePassed\' job', async function () {
      await processProjectStarted(this.project)
      expect(jobService.createJob).to.have.been.calledWithMatch('projectArtifactDeadlinePassed', this.project.id)
    })<commit_msg>fix intemittently braking test by making sure to clean up nock<commit_after>/* eslint-env mocha */
/* global expect, testContext */
/* eslint-disable prefer-arrow-callback, no-unused-expressions, max-nested-callbacks */
import nock from 'nock'
import stubs from 'src/test/stubs'
import factory from 'src/test/factories'
import {resetDB, mockIdmUsersById} from 'src/test/helpers'

describe(testContext(__filename), function () {
  beforeEach(resetDB)
  beforeEach(function () {
    stubs.chatService.enable()
    stubs.jobService.enable()
  })
  afterEach(function () {
    stubs.chatService.disable()
    stubs.jobService.disable()
  })

  describe('processProjectStarted()', async function () {
    const chatService = require('src/server/services/chatService')
    const jobService = require('src/server/services/jobService')
    const {processProjectStarted} = require('../projectStarted')
    beforeEach(async function () {
      nock.cleanAll()
      this.project = await factory.create('project')
      this.players = await mockIdmUsersById(this.project.playerIds, null, {strict: true, times: 10})
      this.playerHandles = this.players.map(p => p.handle)
    })

    afterEach(function () {
      nock.cleanAll()
    })

    it('send a welcome message to the project members', async function () {
      await processProjectStarted(this.project)
      expect(chatService.sendDirectMessage).to.have.been.calledWithMatch(this.playerHandles, 'Welcome to the')
    })

    it('creates a \'projectArtifactDeadlinePassed\' job', async function () {
      await processProjectStarted(this.project)
      expect(jobService.createJob).to.have.been.calledWithMatch('projectArtifactDeadlinePassed', this.project.id)
    })
{'fraction_non_alphanumeric': 0.1279317697228145, 'fraction_numerical': 0.0012183978068839476, 'mean_word_length': 4.279742765273312, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6073481', 'n_tokens_mistral': 983, 'n_tokens_neox': 968, 'n_words': 189}