import assert from 'assert';

import Lab from 'lab';
export const lab = Lab.script();

import nmo from '../src/nmo.js';


lab.experiment('nmo', () => {
  lab.test('throws for api commands if config not loaded', (done) => {
    nmo.config = null;
    assert.throws(
      function () {
        nmo.commands.help();
      },
      Error
    );
    done();
  });

  lab.test('throws for cli commands if config not loaded', (done) => {
    nmo.config = null;
    assert.throws(
      function () {
        nmo.cli.help();
      },
      Error
    );
    done();
  });

  lab.test('does not throw for cli commands if config not loaded', (done) => {
    nmo.config = null;
    nmo.load({nmoconf: __dirname + '/fixtures/randomini'}).then(() => {
      nmo.cli.help().then(() => {
        done();
      });
    });
  });

  lab.test('rejects on failure', (done) => {
    nmo.load({nmoconf: 'bler'}).catch(() => {
      done();
    });
  });

  lab.test('has a version property', (done) => {
    nmo.config = null;
    nmo.load({nmoconf: __dirname + '/fixtures/randomini'}).then(() => {
      assert.ok(nmo.version);
      done();
    });
  });
});
