<commit_before>var assert = require('chai').assert;
var BaseMailer = require('../lib/BaseMailer');

describe('BaseMailer', function () {
  it('Should properly export', function () {
    assert.isFunction(BaseMailer);
    assert.isFunction(BaseMailer.prototype.getConfig);
    assert.isFunction(BaseMailer.prototype.setConfig);
    assert.isFunction(BaseMailer.prototype.getFrom);
    assert.isFunction(BaseMailer.prototype.setFrom);
    assert.isFunction(BaseMailer.prototype.getTo);
    assert.isFunction(BaseMailer.prototype.setTo);
    assert.isFunction(BaseMailer.prototype.getSubject);
    assert.isFunction(BaseMailer.prototype.setSubject);
    assert.isFunction(BaseMailer.prototype.getText);
    assert.isFunction(BaseMailer.prototype.setText);
    assert.isFunction(BaseMailer.prototype.getHtml);
    assert.isFunction(BaseMailer.prototype.setHtml);
    assert.isFunction(BaseMailer.prototype.send);

    assert.throw(function () {
      BaseMailer.prototype.send();
    }, Error);
  });

  it('Should properly make objects configurable', function () {
    var mailer = new BaseMailer();

    assert.notOk(mailer.getConfig('foo'));
    assert.instanceOf(mailer.setConfig('foo', 'bar'), BaseMailer);
    assert.equal(mailer.getConfig('foo'), 'bar');
  });

  it('Should properly create mailer with pre-defined config', function () {
    var mailer = new BaseMailer({
      from: '<EMAIL>',
      transporter: {
        bar: 'foo',
        foo: {
          bar: 'foo'
        }
      }
    });

    assert.equal(mailer.getConfig('from'), '<EMAIL>');
    assert.equal(mailer.getConfig('transporter').bar, 'foo');
    assert.deepEqual(mailer.getConfig('transporter').foo, {bar: 'foo'});
    assert.notOk(mailer.getConfig('NOT_EXISTS'));
  });

  it('Should properly get/set from value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getFrom());
    assert.instanceOf(mailer.setFrom('<EMAIL>'), BaseMailer);
    assert.equal(mailer.getFrom(), '<EMAIL>');
  });

  it('Should properly get/set to value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getTo());
    assert.instanceOf(mailer.setTo('<EMAIL>'), BaseMailer);
    assert.equal(mailer.getTo(), '<EMAIL>');
  });

  it('Should properly get/set subject value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getSubject());
    assert.instanceOf(mailer.setSubject('Hey'), BaseMailer);
    assert.equal(mailer.getSubject(), 'Hey');
  });

  it('Should properly get/set text value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getText());
    assert.instanceOf(mailer.setText('Message'), BaseMailer);
    assert.equal(mailer.getText(), 'Message');
  });

  it('Should properly get/set html value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getHtml());
    assert.instanceOf(mailer.setHtml('<h1>Message</h1>'), BaseMailer);
    assert.equal(mailer.getHtml(), '<h1>Message</h1>');
  });

  it('Should properly throw error on send', function () {
    var mailer = new BaseMailer();
    assert.throw(function () {
      mailer.send();
    }, Error);
  });
});
<commit_msg>Improve test for base configurable<commit_after>var assert = require('chai').assert;
var BaseMailer = require('../lib/BaseMailer');

describe('BaseMailer', function () {
  it('Should properly export', function () {
    assert.isFunction(BaseMailer);
    assert.isFunction(BaseMailer.prototype.getConfig);
    assert.isFunction(BaseMailer.prototype.setConfig);
    assert.isFunction(BaseMailer.prototype.getFrom);
    assert.isFunction(BaseMailer.prototype.setFrom);
    assert.isFunction(BaseMailer.prototype.getTo);
    assert.isFunction(BaseMailer.prototype.setTo);
    assert.isFunction(BaseMailer.prototype.getSubject);
    assert.isFunction(BaseMailer.prototype.setSubject);
    assert.isFunction(BaseMailer.prototype.getText);
    assert.isFunction(BaseMailer.prototype.setText);
    assert.isFunction(BaseMailer.prototype.getHtml);
    assert.isFunction(BaseMailer.prototype.setHtml);
    assert.isFunction(BaseMailer.prototype.send);

    assert.throw(function () {
      BaseMailer.prototype.send();
    }, Error);
  });

  it('Should properly make objects configurable', function () {
    var mailer = new BaseMailer();

    assert.notOk(mailer.getConfig('foo'));
    assert.instanceOf(mailer.setConfig('foo', 'bar'), BaseMailer);
    assert.instanceOf(mailer.setConfig('transporter', {foo: 'bar'}), BaseMailer);
    assert.deepEqual(mailer.getConfig('transporter'), {foo: 'bar'});
    assert.equal(mailer.getConfig('transporter').foo, 'bar');
    assert.equal(mailer.getConfig('foo'), 'bar');
  });

  it('Should properly create mailer with pre-defined config', function () {
    var mailer = new BaseMailer({
      from: '<EMAIL>',
      to: '<EMAIL>',
      transporter: {
        bar: 'foo',
        foo: {
          bar: 'foo'
        }
      }
    });

    assert.equal(mailer.getConfig('from'), '<EMAIL>');
    assert.equal(mailer.getConfig('to'), '<EMAIL>');
    assert.equal(mailer.getConfig('transporter').bar, 'foo');
    assert.deepEqual(mailer.getConfig('transporter').foo, {bar: 'foo'});
    assert.notOk(mailer.getConfig('NOT_EXISTS'));
  });

  it('Should properly get/set from value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getFrom());
    assert.instanceOf(mailer.setFrom('<EMAIL>'), BaseMailer);
    assert.equal(mailer.getFrom(), '<EMAIL>');
  });

  it('Should properly get/set to value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getTo());
    assert.instanceOf(mailer.setTo('<EMAIL>'), BaseMailer);
    assert.equal(mailer.getTo(), '<EMAIL>');
  });

  it('Should properly get/set subject value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getSubject());
    assert.instanceOf(mailer.setSubject('Hey'), BaseMailer);
    assert.equal(mailer.getSubject(), 'Hey');
  });

  it('Should properly get/set text value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getText());
    assert.instanceOf(mailer.setText('Message'), BaseMailer);
    assert.equal(mailer.getText(), 'Message');
  });

  it('Should properly get/set html value', function () {
    var mailer = new BaseMailer();
    assert.notOk(mailer.getHtml());
    assert.instanceOf(mailer.setHtml('<h1>Message</h1>'), BaseMailer);
    assert.equal(mailer.getHtml(), '<h1>Message</h1>');
  });

  it('Should properly throw error on send', function () {
    var mailer = new BaseMailer();
    assert.throw(function () {
      mailer.send();
    }, Error);
  });
});

{'fraction_non_alphanumeric': 0.1684242241639048, 'fraction_numerical': 0.0012051822838204278, 'mean_word_length': 4.1108545034642034, 'pattern_counts': {'":': 0, '<': 25, '<?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': '1968393', 'n_tokens_mistral': 2105, 'n_tokens_neox': 2080, 'n_words': 341}