<commit_before>var reducer = require('../../src/reducers/settings');

describe('settings reducer', () => {
  it('should return the initial state', () => {
    expect(
      reducer(undefined, {})
    ).to.deep.equal(
      {
        remoteDbUrl: undefined,
        remoteDbUser: undefined,
        remoteDbPassword: <PASSWORD>,
        syncMode: 1,
        enabled: false,
        settingsHash: JSON.stringify(
          {
            remoteDbUrl: undefined,
            remoteDbUser: undefined,
            remoteDbPassword: <PASSWORD>,
            syncMode: 1,
            enabled: false
          }
        )
      }
    )
  })

  it('should not change the passed state', (done) => {

    const state = Object.freeze({});
    reducer(state, {type: 'INVALID'});

    done();
  });

  it('should handle EDIT_SETTINGS when there is no change', () => {
    expect(
      reducer({
          remoteDbUrl: undefined,
          remoteDbUser: undefined,
          remoteDbPassword: <PASSWORD>,
          syncMode: 1,
          enabled: false,
          settingsHash: undefined
        },
        {
          type: 'EDIT_SETTINGS',
          settings: {
            remoteDbUrl: undefined,
            remoteDbUser: undefined,
            remoteDbPassword: <PASSWORD>,
            syncMode: 1,
            enabled: false
          }
        }
      )
    ).to.deep.equal(
      {
        remoteDbUrl: undefined,
        remoteDbUser: undefined,
        remoteDbPassword: <PASSWORD>,
        syncMode: 1,
        enabled: false,
        settingsHash: undefined
      }
    )
  })

  it('should handle EDIT_SETTINGS when there is a change', () => {
    expect(
      reducer({
          remoteDbUrl: undefined,
          remoteDbUser: undefined,
          remoteDbPassword: <PASSWORD>,
          syncMode: 1,
          enabled: false,
          settingsHash: undefined
        },
        {
          type: 'EDIT_SETTINGS',
          settings: {
            remoteDbUrl: 'http://example.com',
            remoteDbUser: 'test-user',
            remoteDbPassword: '<PASSWORD>',
            syncMode: 3,
            enabled: true
          }
        }
      )
    ).to.deep.equal(
      {
        remoteDbUrl: 'http://example.com',
        remoteDbUser: 'test-user',
        remoteDbPassword: '<PASSWORD>-pwd',
        syncMode: 3,
        enabled: true,
        settingsHash: JSON.stringify(
          {
            remoteDbUrl: 'http://example.com',
            remoteDbUser: 'test-user',<commit_msg>Refactors the settings reducer test<commit_after>var reducer = require('../../src/reducers/settings');

const initialStateSpecification = {
  remoteDbUrl: undefined,
  remoteDbUser: undefined,
  remoteDbPassword: <PASSWORD>,
  syncMode: 1,
  enabled: false,
  settingsHash: JSON.stringify(
    {
      remoteDbUrl: undefined,
      remoteDbUser: undefined,
      remoteDbPassword: undefined,
      syncMode: 1,
      enabled: false
    }
  )
}

describe('settings reducer', () => {
  it('should return the initial state', () => {
    expect(
      reducer(undefined, {})
    ).to.deep.equal(initialStateSpecification)
  })

  it('should not change the passed state', (done) => {

    const state = Object.freeze({});
    reducer(state, {type: 'INVALID'});

    done();
  });

  it('should handle EDIT_SETTINGS when there is no change', () => {
    expect(
      reducer(initialStateSpecification,
        {
          type: 'EDIT_SETTINGS',
          settings: {
            remoteDbUrl: undefined,
            remoteDbUser: undefined,
            remoteDbPassword: <PASSWORD>,
            syncMode: 1,
            enabled: false
          }
        }
      )
    ).to.deep.equal(initialStateSpecification)
  })

  it('should handle EDIT_SETTINGS when there is a change', () => {
    expect(
      reducer(initialStateSpecification,
        {
          type: 'EDIT_SETTINGS',
          settings: {
            remoteDbUrl: 'http://example.com',
            remoteDbUser: 'test-user',
            remoteDbPassword: '<PASSWORD>',
            syncMode: 3,
            enabled: true
          }
        }
      )
    ).to.deep.equal(
      {
        remoteDbUrl: 'http://example.com',
        remoteDbUser: 'test-user',
        remoteDbPassword: '<PASSWORD>',
        syncMode: 3,
        enabled: true,
        settingsHash: JSON.stringify(
          {
            remoteDbUrl: 'http://example.com',
            remoteDbUser: 'test-user',
{'fraction_non_alphanumeric': 0.1195750452079566, 'fraction_numerical': 0.002938517179023508, 'mean_word_length': 1.7830188679245282, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '98691', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1238, 'n_words': 267}