<commit_before>const lib = require('../src/index');

describe('TESTS', () => {

  describe('Generate', () => {

    test('should return a storage', (done) => {
      lib.generatePassword('secret', (err, storage) => {
        if (err) return done(err);

        const params = storage.split(':');
        expect(params.length).toBe(2);

        done();
      });
    });

    test('should generate a salt', (done) => {
      lib.generatePassword('secret', (err, storage) => {
        if (err) return done(err);

        const params = storage.split(':');
        const salt = new Buffer(params[0], 'base64');
        expect(salt.length).toBe(32);

        done();
      });
    });

    test('should generate a hash', (done) => {
      lib.generatePassword('secret', (err, storage) => {
        if (err) return done(err);

        const params = storage.split(':');
        const hash = new Buffer(params[1], 'base64');
        expect(hash.length).toBe(32);

        done();
      });
    });

  });

  describe('Verify', () => {

    test('should return invalid parameters', (done) => {
      const storage = '';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe('Paremeters length is invalid');
        expect(success).toBe(undefined);

        done();
      });
    });

    test('should return invalid salt', (done) => {
      const storage = 'salt:hash';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe('Salt is invalid');
        expect(success).toBe(undefined);

        done();
      });
    });

    test('should return invalid salt', (done) => {
      const storage = 'KyHLAVL8MHOTLTT/FgqXB+OQF7LxC6jOdXXyHSEPehY=:hash';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe('Hash is invalid');
        expect(success).toBe(undefined);

        done();
      });
    });

    test('should not match', (done) => {
      const storage = 'CoYyMqXHR<KEY>';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe('Passwords not match');
        expect(success).toBe(undefined);

        done();
      });
    });

    test('should match', (done) => {
      const storage = '<KEY>';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe(null);
        expect(success).toBe(true);

        done();
      });
    });

  });

});
<commit_msg>Fixing test<commit_after>const lib = require('../src/index');

describe('TESTS', () => {

  describe('Generate', () => {

    test('should return a storage', (done) => {
      lib.generatePassword('secret', (err, storage) => {
        if (err) return done(err);

        const params = storage.split(':');
        expect(params.length).toBe(2);

        done();
      });
    });

    test('should generate a salt', (done) => {
      lib.generatePassword('secret', (err, storage) => {
        if (err) return done(err);

        const params = storage.split(':');
        const salt = new Buffer(params[0], 'base64');
        expect(salt.length).toBe(32);

        done();
      });
    });

    test('should generate a hash', (done) => {
      lib.generatePassword('secret', (err, storage) => {
        if (err) return done(err);

        const params = storage.split(':');
        const hash = new Buffer(params[1], 'base64');
        expect(hash.length).toBe(32);

        done();
      });
    });

  });

  describe('Verify', () => {

    test('should return invalid parameters', (done) => {
      const storage = '';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe('Paremeters length is invalid');
        expect(success).toBe(undefined);

        done();
      });
    });

    test('should return invalid salt', (done) => {
      const storage = 'salt:hash';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe('Salt is invalid');
        expect(success).toBe(undefined);

        done();
      });
    });

    test('should return invalid hash', (done) => {
      const storage = 'KyHLAVL8MHOTLTT/FgqXB+OQF7LxC6jOdXXyHSEPehY=:hash';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe('Hash is invalid');
        expect(success).toBe(undefined);

        done();
      });
    });

    test('should not match', (done) => {
      const storage = 'CoYyMqXHRHjXEtTbggtEhXjM1jETlVn0sLsv/TiUGhY=:CoYyMqXHRHjXEtTbggtEhXjM1jETlVn0sLsv/TiUGhY=';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe('Passwords not match');
        expect(success).toBe(undefined);

        done();
      });
    });

    test('should match', (done) => {
      const storage = 'CoYyMqXHRHjXEtTbggtEhXjM1jETlVn0sLsv/TiUGhY=:J6fMDmoEmpRDHifaQsjXQWJPY0Np0lIk04XrFjbyd+s=';

      lib.verifyPassword('secret', storage, (err, success) => {
        expect(err).toBe(null);
        expect(success).toBe(true);

        done();
      });
    });

  });

});

{'fraction_non_alphanumeric': 0.18489738991831042, 'fraction_numerical': 0.007770472205618649, 'mean_word_length': 2.5178696566222847, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '2300684', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1557, 'n_words': 295}