'use strict';

/* eslint-disable func-names */
/* eslint-disable prefer-arrow-callback */

const supertest = require('supertest');
const Xible = require('..');

const CONFIG_PATH = '~/.xible/config.json';
const xible = new Xible({
  configPath: CONFIG_PATH
});

describe('/api/nodepacks', function () {
  before(function () {
    this.timeout(10000);
    return xible.init();
  });

  after(function () {
    return xible.close();
  });

  describe('GET /', function () {
    it('should return list of nodepacks', function () {
      return supertest(xible.expressApp)
      .get('/api/nodepacks')
      .expect(200);
    });
  });

  describe('GET /:nodePackName', function () {
    before(function () {
      this.timeout(120000);

      return supertest(xible.expressApp)
      .patch('/api/registry/nodepacks/stream/install')
      .expect(200);
    });

    it('existing should return 200', function () {
      return supertest(xible.expressApp)
      .get('/api/nodepacks/stream')
      .expect(200);
    });
  });

  describe('DELETE /:nodePackName', function () {
    it('should delete nodepack', function () {
      return supertest(xible.expressApp)
      .delete('/api/nodepacks/stream')
      .expect(200);
    });

    it('should return 404', function () {
      return supertest(xible.expressApp)
      .get('/api/nodepacks/stream')
      .expect(404);
    });
  });
});

@@ -84,16 +84,50 @@
 ack */%0A%0A
+const assert = require('assert');%0A
 const su
@@ -186,16 +186,64 @@
 e('..');
+%0Aconst packageJson = require('../package.json');
 %0A%0Aconst 
@@ -692,32 +692,728 @@
 ct(200);%0A    %7D);
+%0A%0A    it('should contain all default nodepacks', async function () %7B%0A      const defaultNodePackNames = Object.keys(packageJson.dependencies)%0A      .filter((packageName) =%3E packageName.startsWith('xible-np-') %7C%7C packageName.startsWith('xible-nodepack-'))%0A      .map((packageName) =%3E (%0A        packageName.startsWith('xible-np-')%0A          ? packageName.substring(9)%0A          : packageName.substring(15)%0A      ));%0A%0A      const res = await supertest(xible.expressApp)%0A      .get('/api/nodepacks');%0A%0A      const hostedNodePackNames = Object.keys(res.body);%0A      assert(defaultNodePackNames.every(%0A        (defaultNodePackName) =%3E hostedNodePackNames.includes(defaultNodePackName)%0A      ));%0A    %7D);
 %0A  %7D);%0A%0A  descri

Test for completeness of hosted nodepacks vs installed.