<commit_before>'use strict';

const defaultGame = require('../js/shared/defaultGame');
const describe = require('mocha').describe;
const expect = require('expect');
const GameHelpers = require('../js/shared/GameHelpers');
const Immutable = require('immutable');
const it = require('mocha').it;


describe('GameHelpers', () => {
  it('getNextWordIndex should work', () => {
    let game = defaultGame;

    // No words available
    expect(() => {
      GameHelpers.getNextWordIndex(game);
    }).toThrow(Error);

    game = game.update('words', (words) => {
      return words
        .push(Immutable.fromJS({word: 'word0', index: 0, inBowl:
        .push(Immutable.fromJS({word: 'word1', index: 1, inBowl: false}));
    });

    // Still no words in bowl
    expect(() => {
      GameHelpers.getNextWordIndex(game);
    }).toThrow(Error); // no words available

    game = game.update('words', (words) => {
      return words
        .push(Immutable.fromJS({word: 'word2', index: 2, inBowl: true}))
        .push(Immutable.fromJS({word: 'word3', index: 3, inBowl: false}))
        .push(Immutable.fromJS({word: 'word4', index: 4, inBowl: false}));
    });

    // there is only one word in the bowl so it should be chosen
    expect(GameHelpers.getNextWordIndex(game)).toEqual(2);
  });

  it('playerIsJoined should work', () => {
    let game = defaultGame;
    const userId = 'userId';
    expect(GameHelpers.playerIsJoined(game, userId)).toEqual(false);
    game = game.set('userId', userId);
    expect(GameHelpers.playerIsJoined(game, userId)).toEqual(false);
    game = game.set('players', game.get('players').push(Immutable.fromJS({id: 'notUserId'})));
    expect(GameHelpers.playerIsJoined(game, userId)).toEqual(false);<commit_msg>Fixed typos/bad merge/something in unit test.<commit_after>'use strict';

const defaultGame = require('../js/shared/defaultGame');
const describe = require('mocha').describe;
const expect = require('expect');
const GameHelpers = require('../js/shared/GameHelpers');
const Immutable = require('immutable');
const it = require('mocha').it;


describe('GameHelpers', () => {
  it('getNextWordIndex should work', () => {
    let game = defaultGame;

    // No words available
    expect(() => {
      GameHelpers.getNextWordIndex(game);
    }).toThrow(Error);

    game = game.set('words', game.get('words')
      .push(Immutable.fromJS({word: 'word0', index: 0, inBowl: false}))
      .push(Immutable.fromJS({word: 'word1', index: 1, inBowl: false})));

    // Still no words in bowl
    expect(() => {
      GameHelpers.getNextWordIndex(game);
    }).toThrow(Error); // no words available

    game = game.set('words', game.get('words')
      .push(Immutable.fromJS({word: 'word2', index: 2, inBowl: true}))
      .push(Immutable.fromJS({word: 'word3', index: 3, inBowl: false}))
      .push(Immutable.fromJS({word: 'word4', index: 4, inBowl: false})));

    // there is only one word in the bowl so it should be chosen
    expect(GameHelpers.getNextWordIndex(game)).toEqual(2);
  });

  it('playerIsJoined should work', () => {
    let game = defaultGame;
    const userId = 'userId';
    expect(GameHelpers.playerIsJoined(game, userId)).toEqual(false);
    game = game.set('userId', userId);
    expect(GameHelpers.playerIsJoined(game, userId)).toEqual(false);
    game = game.set('players', game.get('players').push(Immutable.fromJS({id: 'notUserId'})));
    expect(GameHelpers.playerIsJoined(game, userId)).toEqual(false);
{'fraction_non_alphanumeric': 0.17662337662337663, 'fraction_numerical': 0.006349206349206349, 'mean_word_length': 3.9656160458452723, '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': '7452039', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1114, 'n_words': 239}