<commit_before>import Game from '../../app/scripts/models/game.js';

describe('game', function () {

  it('should preserve players when continuing in 1P mode', function () {
    const game = new Game();
    game.setPlayers({ gameType: '1P' });
    game.players[0].score = 10;
    game.players[1].score = 20;
    game.setPlayers({ gameType: '1P' });
    expect(game.players).to.have.length(2);
    expect(game.players[0].type).to.equal('human');
    expect(game.players[0].score).to.equal(10);
    expect(game.players[1].type).to.equal('ai');
    expect(game.players[1].score).to.equal(20);
  });

  it('should preserve players when continuing in 2P mode', function () {
    const game = new Game();
    game.setPlayers({ gameType: '2P' });
    game.players[0].score = 12;
    game.players[1].score = 16;
    game.setPlayers({ gameType: '2P' });
    expect(game.players).to.have.length(2);
    expect(game.players[0].type).to.equal('human');
    expect(game.players[0].score).to.equal(12);
    expect(game.players[1].type).to.equal('human');
    expect(game.players[1].score).to.equal(16);
  });

  it('should initialize new players when switching from 1P to 2P', function () {
    const game = new Game();
    game.setPlayers({ gameType: '1P' });
    game.players[0].score = 10;
    game.players[1].score = 15;
    game.setPlayers({ gameType: '2P' });
    expect(game.players).to.have.length(2);
    expect(game.players[0].type).to.equal('human');
    expect(game.players[0].score).to.equal(0);
    expect(game.players[1].type).to.equal('human');
    expect(game.players[1].score).to.equal(0);
  });

  it('should initialize new players when switching from 2P to 1P', function () {<commit_msg>Write test for player preservation in Online mode<commit_after>import Game from '../../app/scripts/models/game.js';

describe('game', function () {

  it('should preserve players when continuing in 1P mode', function () {
    const game = new Game();
    game.setPlayers({ gameType: '1P' });
    game.players[0].score = 10;
    game.players[1].score = 20;
    game.setPlayers({ gameType: '1P' });
    expect(game.players).to.have.length(2);
    expect(game.players[0].type).to.equal('human');
    expect(game.players[0].score).to.equal(10);
    expect(game.players[1].type).to.equal('ai');
    expect(game.players[1].score).to.equal(20);
  });

  it('should preserve players when continuing in 2P mode', function () {
    const game = new Game();
    game.setPlayers({ gameType: '2P' });
    game.players[0].score = 12;
    game.players[1].score = 16;
    game.setPlayers({ gameType: '2P' });
    expect(game.players).to.have.length(2);
    expect(game.players[0].type).to.equal('human');
    expect(game.players[0].score).to.equal(12);
    expect(game.players[1].type).to.equal('human');
    expect(game.players[1].score).to.equal(16);
  });

  it('should preserve players when continuing in Online mode', function () {
    const game = new Game();
    game.setPlayers({
      gameType: 'online',
      players: [
        { name: 'Abott', color: 'red' },
        { name: 'Costello', color: 'blue' }
      ],
      localPlayer: { name: 'Costello', color: 'blue' }
    });
    game.players[0].score = 12;
    game.players[1].score = 16;
    game.setPlayers({ gameType: 'online' });
    expect(game.players).to.have.length(2);
    expect(game.players[0].type).to.equal('online');
    expect(game.players[0].score).to.equal(12);
    expect(game.players[1].type).to.equal('human');
    expect(game.players[1].score).to.equal(16);
  });

  it('should initialize new players when switching from 1P to 2P', function () {
    const game = new Game();
    game.setPlayers({ gameType: '1P' });
    game.players[0].score = 10;
    game.players[1].score = 15;
    game.setPlayers({ gameType: '2P' });
    expect(game.players).to.have.length(2);
    expect(game.players[0].type).to.equal('human');
    expect(game.players[0].score).to.equal(0);
    expect(game.players[1].type).to.equal('human');
    expect(game.players[1].score).to.equal(0);
  });

  it('should initialize new players when switching from 2P to 1P', function () {
{'fraction_non_alphanumeric': 0.1948431038676721, 'fraction_numerical': 0.030406227195329604, 'mean_word_length': 3.594413407821229, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7557238', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1414, 'n_words': 255}