import { expect } from 'aegir/utils/chai.js';
import {
  getDescribe,
  getIt
} from '../utils/mocha.js';
import all from 'it-all';
export function testDisabled(factory, options) {
  const describe = getDescribe(options);
  const it = getIt(options);
  describe('disabled', function () {
    this.timeout(80 * 1000);
    let nodeA;
    let nodeB;
    before(async () => {
      nodeA = (await factory.spawn({ ipfsOptions: { config: { Routing: { Type: 'none' } } } })).api;
      nodeB = (await factory.spawn()).api;
      const nodeBId = await nodeB.id();
      await nodeA.swarm.connect(nodeBId.addresses[0]);
    });
    after(() => factory.clean());
    it('should error when DHT not available', async () => {
      const events = await all(nodeA.dht.get('/ipns/12D3KooWQMSMXmsBvs5YDEQ6tXsaFv9tjuzmDmEvusaiQSFdrJdN'));
      expect(events.filter(event => event.name === 'QUERY_ERROR')).to.not.be.empty();
    });
  });
}