<commit_before>const chai = require('chai')
const path = require('path')
// Actual Test Imports
const Settings = require('./../app/utils/settings')
const defaultSettings = require('./../app/utils/defaultSettings')

const testFileLocation = path.join(__dirname, 'testFile')
const testMissingFileLocation = path.join(__dirname, 'test-missing.json')

chai.should()

describe('Settings', () => {
  let settings
  beforeEach(() => {
    settings = new Settings(testFileLocation)
  })

  it('should initialize with default settings', () => {
    settings.data.should.be.deep.equal(defaultSettings)
  })

  it('should load missing settings', () => {
    settings = new Settings(testMissingFileLocation)
    defaultSettings['microbreak'] = false
    settings.data.should.be.deep.equal(defaultSettings)
  })

  it('should set a new value in the runtime', () => {
    settings.set('test_key', 'test_value')
    settings.get('test_key').should.be.equal('test_value')
  })

  it('should save a value to a file', (done) => {<commit_msg>Enhance test<commit_after>const chai = require('chai')
const path = require('path')
const fs = require('fs')
// Actual Test Imports
const Settings = require('./../app/utils/settings')
const defaultSettings = require('./../app/utils/defaultSettings')

const testFileLocation = path.join(__dirname, 'testFile')
const testMissingFileLocation = path.join(__dirname, 'test-missing.json')
const testMissingFileCopyLocation = path.join(__dirname, 'test-missing-copy.json')

chai.should()

describe('Settings', () => {
  let settings
  beforeEach(() => {
    settings = new Settings(testFileLocation)
  })

  it('should initialize with default settings', () => {
    settings.data.should.be.deep.equal(defaultSettings)
  })

  it('should load missing settings', () => {
    const testData = fs.readFileSync(testMissingFileLocation)
    fs.writeFileSync(testMissingFileCopyLocation, testData)
    // we create copy to not worry about git changes to `test-missing.json`
    settings = new Settings(testMissingFileCopyLocation)
    defaultSettings['microbreak'] = false
    settings.data.should.be.deep.equal(defaultSettings)
  })

  it('should set a new value in the runtime', () => {
    settings.set('test_key', 'test_value')
    settings.get('test_key').should.be.equal('test_value')
  })

  it('should save a value to a file', (done) => {
{'fraction_non_alphanumeric': 0.14989384288747346, 'fraction_numerical': 0.0, 'mean_word_length': 4.569739952718676, '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': '62268', 'n_tokens_mistral': 694, 'n_tokens_neox': 681, 'n_words': 156}