<commit_before>/* eslint-disable prefer-arrow-callback */
const { expect } = require('chai');

describe('Mservice suite', function testSuite() {
  const Mservice = require('../src');

  it('creates service with no plugins', function test() {
    expect(() => new Mservice({ plugins: [] })).to.not.throw();
  });

  it('creates service with default configuration', function test() {
    expect(() => new Mservice()).to.not.throw();
  });

  it('creates service with validator enabled', function test() {
    expect(() => new Mservice({ plugins: ['validator'] })).to.not.throw();
  });

  it('creates services with logger enabled', function test() {
    expect(() => new Mservice({ plugins: ['logger'] })).to.not.throw();
  });

  it('creates service with amqp enabled', function test() {
    expect(() => new Mservice({ plugins: ['amqp'] })).to.not.throw();
  });

  it('creates service with redis enabled', function test() {
    expect(new Mservice({ plugins: ['redisCluster'] })).to.not.throw();
  });

  it('creates service with hooks enabled', function test() {
    expect(() => new Mservice({
      plugins: [],
      hooks: {
        'event:test': function eventTest() {
          return 'OK';
        },
        'event:valid': [
          function eventValid() {
            return 1;
          },
          function eventValid2() {
            return 2;
          },
        ],
      },
    })).to.not.throw();
  });

  it('creates service with all plugins enabled', function test() {
    expect(() => {
      this.service = new Mservice({
        plugins: ['validator', 'logger', 'amqp', 'redisCluster'],
        redis: global.SERVICES.redis,
        amqp: global.SERVICES.amqp,
        logger: true,
        hooks: {
          masala: function chai(a, b) {
            return `chai with ${a} and ${b}`;
          },
        },
      });
    }).to.not.throw();
  });

  it('able to connect to all services', function test() {
    const AMQPTransport = require('ms-amqp-transport');
    const { Cluster } = require('ioredis');

    return this.service.connect().reflect()
      .then(result => {
        expect(result.isFulfilled()).to.be.eq(true);
        return result.value();
      })
      .spread((amqp, redis) => {
        expect(amqp).to.be.instanceof(AMQPTransport);
        expect(redis).to.be.instanceof(Cluster);
      });
  });

  it('init hooks and waits for their completion', function test() {
    return this.service
      .postHook('masala', 'dorothy', 'chris')
      .reflect()
      .then(result => {
        expect(result.isFulfilled()).to.be.eq(true);
        expect(result.value()).to.be.deep.eq([
          'chai with dorothy and chris',
        ]);
      });
  });

  it('able to disconnect from all services', function test() {
    return this.service
      .close()
      .reflect()
      .then(result => {
        expect(result.isFulfilled()).to.be.eq(true);
      });
  });
});
<commit_msg>tests: fixes missing () => invocation<commit_after>/* eslint-disable prefer-arrow-callback */
const { expect } = require('chai');

describe('Mservice suite', function testSuite() {
  const Mservice = require('../src');

  it('creates service with no plugins', function test() {
    expect(() => new Mservice({ plugins: [] })).to.not.throw();
  });

  it('creates service with default configuration', function test() {
    expect(() => new Mservice()).to.not.throw();
  });

  it('creates service with validator enabled', function test() {
    expect(() => new Mservice({ plugins: ['validator'] })).to.not.throw();
  });

  it('creates services with logger enabled', function test() {
    expect(() => new Mservice({ plugins: ['logger'] })).to.not.throw();
  });

  it('creates service with amqp enabled', function test() {
    expect(() => new Mservice({ plugins: ['amqp'] })).to.not.throw();
  });

  it('creates service with redis enabled', function test() {
    expect(() => new Mservice({ plugins: ['redisCluster'] })).to.not.throw();
  });

  it('creates service with hooks enabled', function test() {
    expect(() => new Mservice({
      plugins: [],
      hooks: {
        'event:test': function eventTest() {
          return 'OK';
        },
        'event:valid': [
          function eventValid() {
            return 1;
          },
          function eventValid2() {
            return 2;
          },
        ],
      },
    })).to.not.throw();
  });

  it('creates service with all plugins enabled', function test() {
    expect(() => {
      this.service = new Mservice({
        plugins: ['validator', 'logger', 'amqp', 'redisCluster'],
        redis: global.SERVICES.redis,
        amqp: global.SERVICES.amqp,
        logger: true,
        hooks: {
          masala: function chai(a, b) {
            return `chai with ${a} and ${b}`;
          },
        },
      });
    }).to.not.throw();
  });

  it('able to connect to all services', function test() {
    const AMQPTransport = require('ms-amqp-transport');
    const { Cluster } = require('ioredis');

    return this.service.connect().reflect()
      .then(result => {
        expect(result.isFulfilled()).to.be.eq(true);
        return result.value();
      })
      .spread((amqp, redis) => {
        expect(amqp).to.be.instanceof(AMQPTransport);
        expect(redis).to.be.instanceof(Cluster);
      });
  });

  it('init hooks and waits for their completion', function test() {
    return this.service
      .postHook('masala', 'dorothy', 'chris')
      .reflect()
      .then(result => {
        expect(result.isFulfilled()).to.be.eq(true);
        expect(result.value()).to.be.deep.eq([
          'chai with dorothy and chris',
        ]);
      });
  });

  it('able to disconnect from all services', function test() {
    return this.service
      .close()
      .reflect()
      .then(result => {
        expect(result.isFulfilled()).to.be.eq(true);
      });
  });
});

{'fraction_non_alphanumeric': 0.18174090445426724, 'fraction_numerical': 0.0010200612036722204, 'mean_word_length': 2.4934679334916865, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '4355143', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1741, 'n_words': 422}