<commit_before>'use strict';

var chai = require('chai');
var should = chai.should();

var Mnemonic = require('..');
var errors = require('bitcore').errors;
var bip39_vectors = require('./data/fixtures.json');

describe('Mnemonic', function() {
  this.timeout(10000);

  it('should initialize the class', function() {
    should.exist(Mnemonic);
  });

  describe('# Mnemonic', function() {

    describe('Constructor', function() {
      it('does not require new keyword', function() {
        var mnemonic = Mnemonic(); // jshint ignore:line
        mnemonic.should.be.instanceof(Mnemonic);
      });

      it('should fail with invalid data', function() {
        (function() {
          return new Mnemonic({});
        }).should.throw(errors.InvalidArgument);
      });

      it('should fail with unknown word list', function() {
        (function() {
          return new Mnemonic('pilote foster august tomorrow kit daughter unknown awesome model town village master');
        }).should.throw(errors.Mnemonic.UnknownWordlist);
      });

      it('should fail with invalid mnemonic', function() {
        (function() {
          return new Mnemonic('monster foster august tomorrow kit daughter unknown awesome model town village pilot');
        }).should.throw(errors.Mnemonic.InvalidMnemonic);
      });

      it('should fail with invalid ENT', function() {
        (function() {
          return new Mnemonic(64);
        }).should.throw(errors.InvalidArgument);
      });

      it('constructor defaults to english worldlist', function() {
        var mnemonic = new Mnemonic();
        mnemonic.wordlist.should.equal(Mnemonic.Words.ENGLISH);
      });

      it('allow using different worldlists', function() {
        var mnemonic = new Mnemonic(Mnemonic.Words.SPANISH);
        mnemonic.wordlist.should.equal(Mnemonic.Words.SPANISH);
      });

      it('constructor honor both length and wordlist', function() {
        var mnemonic = new Mnemonic(32 * 7, Mnemonic.Words.SPANISH);
        mnemonic.phrase.split(' ').length.should.equal(21);
        mnemonic.wordlist.should.equal(Mnemonic.Words.SPANISH);
      });

      it('constructor should detect standard wordlist', function() {
        var mnemonic = new Mnemonic('afirmar diseño hielo fideo etapa ogro cambio fideo toalla pomelo número buscar');
        mnemonic.wordlist.should.equal(Mnemonic.Words.SPANISH);
      });

    });


    it('english wordlist is complete', function() {
      Mnemonic.Words.ENGLISH.length.should.equal(2048);
      Mnemonic.Words.ENGLISH[0].should.equal('abandon');
    });

    it('spanish wordlist is complete', function() {
      Mnemonic.Words.SPANISH.length.should.equal(2048);
      Mnemonic.Words.SPANISH[0].should.equal('ábaco');
    });

    it('japanese wordlist is complete', function() {
      Mnemonic.Words.JAPANESE.length.should.equal(2048);
      Mnemonic.Words.JAPANESE[0].should.equal('あいこくしん');
    });

    it('chinese wordlist is complete', function() {
      Mnemonic.Words.CHINESE.length.should.equal(2048);
      Mnemonic.Words.CHINESE[0].should.equal('的');
    });

    it('allows use different phrase lengths', function() {
      var mnemonic;

      mnemonic = new Mnemonic(32 * 4);
      mnemonic.phrase.split(' ').length.should.equal(12);

      mnemonic = new Mnemonic(32 * 5);<commit_msg>Fixed test to use normalized spanish<commit_after>'use strict';

var chai = require('chai');
var should = chai.should();

var Mnemonic = require('..');
var errors = require('bitcore').errors;
var bip39_vectors = require('./data/fixtures.json');

describe('Mnemonic', function() {
  this.timeout(10000);

  it('should initialize the class', function() {
    should.exist(Mnemonic);
  });

  describe('# Mnemonic', function() {

    describe('Constructor', function() {
      it('does not require new keyword', function() {
        var mnemonic = Mnemonic(); // jshint ignore:line
        mnemonic.should.be.instanceof(Mnemonic);
      });

      it('should fail with invalid data', function() {
        (function() {
          return new Mnemonic({});
        }).should.throw(errors.InvalidArgument);
      });

      it('should fail with unknown word list', function() {
        (function() {
          return new Mnemonic('pilote foster august tomorrow kit daughter unknown awesome model town village master');
        }).should.throw(errors.Mnemonic.UnknownWordlist);
      });

      it('should fail with invalid mnemonic', function() {
        (function() {
          return new Mnemonic('monster foster august tomorrow kit daughter unknown awesome model town village pilot');
        }).should.throw(errors.Mnemonic.InvalidMnemonic);
      });

      it('should fail with invalid ENT', function() {
        (function() {
          return new Mnemonic(64);
        }).should.throw(errors.InvalidArgument);
      });

      it('constructor defaults to english worldlist', function() {
        var mnemonic = new Mnemonic();
        mnemonic.wordlist.should.equal(Mnemonic.Words.ENGLISH);
      });

      it('allow using different worldlists', function() {
        var mnemonic = new Mnemonic(Mnemonic.Words.SPANISH);
        mnemonic.wordlist.should.equal(Mnemonic.Words.SPANISH);
      });

      it('constructor honor both length and wordlist', function() {
        var mnemonic = new Mnemonic(32 * 7, Mnemonic.Words.SPANISH);
        mnemonic.phrase.split(' ').length.should.equal(21);
        mnemonic.wordlist.should.equal(Mnemonic.Words.SPANISH);
      });

      it('constructor should detect standard wordlist', function() {
        var mnemonic = new Mnemonic('afirmar diseño hielo fideo etapa ogro cambio fideo toalla pomelo número buscar');
        mnemonic.wordlist.should.equal(Mnemonic.Words.SPANISH);
      });

    });


    it('english wordlist is complete', function() {
      Mnemonic.Words.ENGLISH.length.should.equal(2048);
      Mnemonic.Words.ENGLISH[0].should.equal('abandon');
    });

    it('spanish wordlist is complete', function() {
      Mnemonic.Words.SPANISH.length.should.equal(2048);
      Mnemonic.Words.SPANISH[0].should.equal('ábaco');
    });

    it('japanese wordlist is complete', function() {
      Mnemonic.Words.JAPANESE.length.should.equal(2048);
      Mnemonic.Words.JAPANESE[0].should.equal('あいこくしん');
    });

    it('chinese wordlist is complete', function() {
      Mnemonic.Words.CHINESE.length.should.equal(2048);
      Mnemonic.Words.CHINESE[0].should.equal('的');
    });

    it('allows use different phrase lengths', function() {
      var mnemonic;

      mnemonic = new Mnemonic(32 * 4);
      mnemonic.phrase.split(' ').length.should.equal(12);

      mnemonic = new Mnemonic(32 * 5);
{'fraction_non_alphanumeric': 0.14103717026378898, 'fraction_numerical': 0.012589928057553957, 'mean_word_length': 3.06890243902439, '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': '1165655', 'n_tokens_mistral': 2217, 'n_tokens_neox': 1998, 'n_words': 434}