<commit_before><commit_msg>password-update: Add tests for reducer of `password` module<commit_after>import reducer from './index'
import * as actions from './actions'

describe('password-update', () => {
  describe('password reducer', () => {
    it('creates initial state', () => {
      expect(reducer(undefined, {})).to.deep.equal({
        oldPassword: '',
        newPassword: '',
        newPasswordRepeat: '',
        newPasswordValidationErrors: null
      })
    });

    it('handles UPDATE_OLD_PASSWORD', () => {
      const stateBefore = {
        oldPassword: ''
      }

      const expectedStateAfter = {
        oldPassword: '<PASSWORD>'
      }

      expect(reducer(stateBefore, actions.updateOldPassword('oldpw'))).to.deep.equal(expectedStateAfter)
    });

    it('handles SET_NEW_PASSWORD', () => {
      const stateBefore = {
        newPassword: ''
      }

      const expectedStateAfter = {
        newPassword: '<PASSWORD>'
      }

      expect(reducer(stateBefore, actions.setNewPassword('<PASSWORD>'))).to.deep.equal(expectedStateAfter)
    });

    it('handles SET_NEW_PASSWORD_VALIDATION_ERRORS', () => {
      const stateBefore = {
        newPasswordValidationErrors: null
      }

      const errors = {
        'rule1': true,
        'rule3': true
      }
      const expectedStateAfter = {
        newPasswordValidationErrors: errors
      }

      expect(reducer(stateBefore, actions.setNewPasswordValidationErrors(errors))).to.deep.equal(expectedStateAfter)
    });

    it('handles UPDATE_NEW_PASSWORD_REPEAT', () => {
      const stateBefore = {
        newPasswordRepeat: ''
      }

      const expectedStateAfter = {
        newPasswordRepeat: '<PASSWORD>'
      }

      expect(reducer(stateBefore, actions.updateNewPasswordRepeat('newpwrepeat'))).to.deep.equal(expectedStateAfter)
    });
  })
})
{'fraction_non_alphanumeric': 0.13532608695652174, 'fraction_numerical': 0.0010869565217391304, 'mean_word_length': 2.8274428274428276, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, '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': '6201066', 'n_tokens_mistral': 536, 'n_tokens_neox': 518, 'n_words': 80}