UNPKG

interface-ipfs-core

Version:

A test suite and interface you can use to implement a IPFS core interface.

44 lines (33 loc) 1.06 kB
/* eslint-env mocha */ import { nanoid } from 'nanoid' import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' /** * @typedef {import('ipfsd-ctl').Factory} Factory */ /** * @param {Factory} factory * @param {object} options */ export function testRm (factory, options) { const describe = getDescribe(options) const it = getIt(options) describe('.key.rm', () => { /** @type {import('ipfs-core-types').IPFS} */ let ipfs before(async () => { ipfs = (await factory.spawn()).api }) after(() => factory.clean()) it('should rm a key', async function () { this.timeout(30 * 1000) const key = await ipfs.key.gen(nanoid(), { type: 'rsa', size: 2048 }) const removeRes = await ipfs.key.rm(key.name) expect(removeRes).to.exist() expect(removeRes).to.have.property('name', key.name) expect(removeRes).to.have.property('id', key.id) const res = await ipfs.key.list() expect(res.find(k => k.name === key.name)).to.not.exist() }) }) }