<commit_before>import Civ5Save from '../Civ5Save';

const path = require('path');

const TEST_SAVEGAME_V10017 = path.join(__dirname, 'resources', '1.0.0.17.Civ5Save');
const TEST_SAVEGAME_V101135 = path.join(__dirname, 'resources', '1.0.1.135.Civ5Save');
const TEST_SAVEGAME_V101221 = path.join(__dirname, 'resources', '1.0.1.221.Civ5Save');
const TEST_SAVEGAME_V10213 = path.join(__dirname, 'resources', '1.0.2.13.Civ5Save');
const TEST_SAVEGAME_V103279 = path.join(__dirname, 'resources', '1.0.3.279.Civ5Save');
const TEST_SAVEGAME_BROKEN = path.join(__dirname, 'resources', 'broken.Civ5Save');

const NEW_ALWAYS_PEACE = true;
const NEW_ALWAYS_WAR = true;
const NEW_COMPLETE_KILLS = false;
const NEW_CULTURAL_VICTORY = false;
const NEW_DIPLOMATIC_VICTORY = true;
const NEW_DOMINATION_VICTORY = true;
const NEW_LOCK_MODS = true;
const NEW_MAX_TURNS = 123;
const NEW_NEW_RANDOM_SEED = true;
const NEW_NO_BARBARIANS = false;
const NEW_NO_CHANGING_WAR_OR_PEACE = true;
const NEW_NO_CITY_RAZING = false;
const NEW_NO_CULTURE_OVERVIEW_UI = true;
const NEW_NO_ESPIONAGE = false;
const NEW_NO_HAPPINESS = true;
const NEW_NO_POLICIES = true;
const NEW_NO_RELIGION = false;
const NEW_NO_SCIENCE = true;
const NEW_NO_WORLD_CONGRESS = true;
const NEW_ONE_CITY_CHALLENGE = false;
const NEW_PITBOSS = false;
const NEW_POLICY_SAVING = false;
const NEW_PRIVATE_GAME = false;
const NEW_PROMOTION_SAVING = false;
const NEW_RAGING_BARBARIANS = false;
const NEW_RANDOM_PERSONALITIES = false;
const NEW_SCIENCE_VICTORY = false;
const NEW_TIME_VICTORY = true;
const NEW_TURN_TIMER_ENABLED = false;
const NEW_TURN_TIMER_VALUE = 321;
const NEW_TURN_MODE = Civ5Save.TURN_MODES.SIMULTANEOUS;

let savegame10017;
let savegame101135;
let savegame101221;
let savegame10213;
let savegame103279;

function getFileBlob(url) {
  return new Promise(function (resolve, reject) {
    let xhr = new XMLHttpRequest();
    xhr.open('GET', url);
    xhr.responseType = 'blob';
    xhr.addEventListener('load', function() {
      resolve(xhr.response);
    });
    xhr.addEventListener('error', function() {
      reject(xhr.statusText);
    });
    xhr.send();
  });
}

test('Create new Civ5Save instances from file', async () => {
  let fileBlob = await getFileBlob(TEST_SAVEGAME_V10017);
  savegame10017 = await Civ5Save.fromFile(fileBlob);

  fileBlob = await getFileBlob(TEST_SAVEGAME_V101135);
  savegame101135 = await Civ5Save.fromFile(fileBlob);

  fileBlob = await getFileBlob(TEST_SAVEGAME_V101221);
  savegame101221 = await Civ5Save.fromFile(fileBlob);

  fileBlob = await getFileBlob(TEST_SAVEGAME_V10213);
  savegame10213 = await Civ5Save.fromFile(fileBlob);

  fileBlob = await getFileBlob(TEST_SAVEGAME_V103279);
  savegame103279 = await Civ5Save.fromFile(fileBlob);
}, 10000);

test('Get game build', () => {
  expect(savegame10017.gameBuild).toBe('201080');
  expect(savegame101135.gameBuild).toBe('210752');
  expect(savegame101221.gameBuild).toBe('218015');
  expect(savegame10213.gameBuild).toBe('341540');
  expect(savegame103279.gameBuild).toBe('403694');
});

test('Get game version', () => {
  expect(savegame10017.gameVersion).not.toBeDefined();
  expect(savegame101135.gameVersion).not.toBeDefined();<commit_msg>Allow more time for tests since they're still timing out periodically on Travis<commit_after>import Civ5Save from '../Civ5Save';

const path = require('path');

const TEST_SAVEGAME_V10017 = path.join(__dirname, 'resources', '1.0.0.17.Civ5Save');
const TEST_SAVEGAME_V101135 = path.join(__dirname, 'resources', '1.0.1.135.Civ5Save');
const TEST_SAVEGAME_V101221 = path.join(__dirname, 'resources', '1.0.1.221.Civ5Save');
const TEST_SAVEGAME_V10213 = path.join(__dirname, 'resources', '1.0.2.13.Civ5Save');
const TEST_SAVEGAME_V103279 = path.join(__dirname, 'resources', '1.0.3.279.Civ5Save');
const TEST_SAVEGAME_BROKEN = path.join(__dirname, 'resources', 'broken.Civ5Save');

const NEW_ALWAYS_PEACE = true;
const NEW_ALWAYS_WAR = true;
const NEW_COMPLETE_KILLS = false;
const NEW_CULTURAL_VICTORY = false;
const NEW_DIPLOMATIC_VICTORY = true;
const NEW_DOMINATION_VICTORY = true;
const NEW_LOCK_MODS = true;
const NEW_MAX_TURNS = 123;
const NEW_NEW_RANDOM_SEED = true;
const NEW_NO_BARBARIANS = false;
const NEW_NO_CHANGING_WAR_OR_PEACE = true;
const NEW_NO_CITY_RAZING = false;
const NEW_NO_CULTURE_OVERVIEW_UI = true;
const NEW_NO_ESPIONAGE = false;
const NEW_NO_HAPPINESS = true;
const NEW_NO_POLICIES = true;
const NEW_NO_RELIGION = false;
const NEW_NO_SCIENCE = true;
const NEW_NO_WORLD_CONGRESS = true;
const NEW_ONE_CITY_CHALLENGE = false;
const NEW_PITBOSS = false;
const NEW_POLICY_SAVING = false;
const NEW_PRIVATE_GAME = false;
const NEW_PROMOTION_SAVING = false;
const NEW_RAGING_BARBARIANS = false;
const NEW_RANDOM_PERSONALITIES = false;
const NEW_SCIENCE_VICTORY = false;
const NEW_TIME_VICTORY = true;
const NEW_TURN_TIMER_ENABLED = false;
const NEW_TURN_TIMER_VALUE = 321;
const NEW_TURN_MODE = Civ5Save.TURN_MODES.SIMULTANEOUS;

let savegame10017;
let savegame101135;
let savegame101221;
let savegame10213;
let savegame103279;

function getFileBlob(url) {
  return new Promise(function (resolve, reject) {
    let xhr = new XMLHttpRequest();
    xhr.open('GET', url);
    xhr.responseType = 'blob';
    xhr.addEventListener('load', function() {
      resolve(xhr.response);
    });
    xhr.addEventListener('error', function() {
      reject(xhr.statusText);
    });
    xhr.send();
  });
}

test('Create new Civ5Save instances from file', async () => {
  let fileBlob = await getFileBlob(TEST_SAVEGAME_V10017);
  savegame10017 = await Civ5Save.fromFile(fileBlob);

  fileBlob = await getFileBlob(TEST_SAVEGAME_V101135);
  savegame101135 = await Civ5Save.fromFile(fileBlob);

  fileBlob = await getFileBlob(TEST_SAVEGAME_V101221);
  savegame101221 = await Civ5Save.fromFile(fileBlob);

  fileBlob = await getFileBlob(TEST_SAVEGAME_V10213);
  savegame10213 = await Civ5Save.fromFile(fileBlob);

  fileBlob = await getFileBlob(TEST_SAVEGAME_V103279);
  savegame103279 = await Civ5Save.fromFile(fileBlob);
}, 20000);

test('Get game build', () => {
  expect(savegame10017.gameBuild).toBe('201080');
  expect(savegame101135.gameBuild).toBe('210752');
  expect(savegame101221.gameBuild).toBe('218015');
  expect(savegame10213.gameBuild).toBe('341540');
  expect(savegame103279.gameBuild).toBe('403694');
});

test('Get game version', () => {
  expect(savegame10017.gameVersion).not.toBeDefined();
  expect(savegame101135.gameVersion).not.toBeDefined();
{'fraction_non_alphanumeric': 0.1155631188118812, 'fraction_numerical': 0.07271039603960396, 'mean_word_length': 6.305084745762712, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 10, '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': '7564591', 'n_tokens_mistral': 2713, 'n_tokens_neox': 2404, 'n_words': 439}