<commit_before>/* eslint-disable no-unused-expressions */
/* global describe, it, before, after, beforeEach, afterEach */

const sinon = require('sinon');
const chai = require('chai');
const expect = chai.expect;
const fs = require('fs');

const settings = require('../lib/modules/settings');

describe('Settings', function () {
  let sandbox;

  beforeEach(function () {
    sandbox = sinon.sandbox.create();
    sandbox.stub(fs, 'writeFile');
  });

  afterEach(function () {
    sandbox.restore();
  });

  describe('Save option', function () {
    it('should call a write file for valid option value pair', function (done) {
      settings.update({
        'timezone': 'Europe/Paris'
      });
      expect(fs.writeFile).to.be.calledOnce;
      done();
    });
  });
});<commit_msg>Add test for setting with an invalid time zone<commit_after>/* eslint-disable no-unused-expressions */
/* global describe, it, before, after, beforeEach, afterEach */

const sinon = require('sinon');
const chai = require('chai');
const expect = chai.expect;
const fs = require('fs');

const settings = require('../lib/modules/settings');
const helpers = require('../lib/helpers');

describe('Settings', function () {
  let sandbox;

  beforeEach(function () {
    sandbox = sinon.sandbox.create();
    sandbox.stub(fs, 'writeFile');
    sandbox.stub(helpers, 'printError');
  });

  afterEach(function () {
    sandbox.restore();
  });

  describe('Save option', function () {
    it('should call a write file for valid option value pair', function (done) {
      settings.update({
        'timezone': 'Europe/Paris'
      });
      expect(fs.writeFile).to.be.calledOnce;
      done();
    });
    it('should print an error for invalid time zone', function (done) {
      settings.update({
        'timezone': 'Invalid/Timezone'
      });
      expect(helpers.printError).to.be.calledOnce;
      done();
    });
  });
});
{'fraction_non_alphanumeric': 0.16727844782380702, 'fraction_numerical': 0.0, 'mean_word_length': 3.376146788990826, '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': '77558', 'n_tokens_mistral': 582, 'n_tokens_neox': 577, 'n_words': 140}