'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const isSkip = o => Object.prototype.toString.call(o) === '[object Object]' && (o.name || o.reason);
function createSuite(tests, parent) {
  const suite = (factory, options = {}) => {
    Object.keys(tests).forEach(t => {
      const opts = Object.assign({}, options);
      const suiteName = parent ? `${ parent }.${ t }` : t;
      if (Array.isArray(opts.skip)) {
        const skip = opts.skip.map(s => isSkip(s) ? s : {
          name: s,
          reason: '\uD83E\uDD37'
        }).find(s => s.name === suiteName);
        if (skip) {
          opts.skip = skip;
        }
      }
      if (Array.isArray(opts.only)) {
        if (opts.only.includes(suiteName)) {
          opts.only = true;
        }
      }
      tests[t](factory, opts);
    });
  };
  return Object.assign(suite, tests);
}

exports.createSuite = createSuite;
