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

import {processCycleLaunch} from 'src/server/workers/cycleLaunched/worker'

describe(testContext(__filename), function () {
  withDBCleanup()

  describe('processCycleLaunch()', function () {
    describe('when a cycle has been launched', function () {
      beforeEach(async function () {
        this.chapter = await factory.create('chapter')
        this.cycle = await factory.create('cycle', {
          chapterId: this.chapter.id,
          cycleNumber: 3,
        })
        this.pool = await factory.create('pool', {cycleId: this.cycle.id})
      })

      it('begins the process but throws an error when no votes have been submitted', function () {
        return processCycleLaunch(this.cycle).catch(err => {
          expect(err.message).to.match(/^No votes submitted/)
        })
      })
    })
  })
})<commit_msg>no votes in a pool does not throw; it is ignored<commit_after>/* eslint-env mocha */
/* global expect, testContext */
/* eslint-disable prefer-arrow-callback, no-unused-expressions, max-nested-callbacks */
import factory from 'src/test/factories'
import {withDBCleanup} from 'src/test/helpers'

import {processCycleLaunch} from 'src/server/workers/cycleLaunched/worker'

describe(testContext(__filename), function () {
  withDBCleanup()

  describe('processCycleLaunch()', function () {
    describe('when a cycle has been launched', function () {
      beforeEach(async function () {
        this.chapter = await factory.create('chapter')
        this.cycle = await factory.create('cycle', {
          chapterId: this.chapter.id,
          cycleNumber: 3,
        })
        this.pool = await factory.create('pool', {cycleId: this.cycle.id})
      })

      it('does not throw an error when no votes have been submitted', function () {
        expect(processCycleLaunch(this.cycle)).to.not.be.rejected
      })
    })
  })
})
{'fraction_non_alphanumeric': 0.13428571428571429, 'fraction_numerical': 0.0009523809523809524, 'mean_word_length': 3.2530364372469633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2398584', 'n_tokens_mistral': 608, 'n_tokens_neox': 604, 'n_words': 144}