@apillon/sdk
Version:
▶◀ Apillon SDK for NodeJS ▶◀
56 lines • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const storage_1 = require("../modules/storage/storage");
const helper_1 = require("./helpers/helper");
describe('IPNS tests for StorageBucket', () => {
let storage;
let bucketUuid;
let newIpnsUuid;
beforeAll(async () => {
storage = new storage_1.Storage((0, helper_1.getConfig)());
bucketUuid = (0, helper_1.getBucketUUID)();
});
test('List IPNS records in a bucket', async () => {
const response = await storage.bucket(bucketUuid).listIpnsNames();
expect(response.items).toBeInstanceOf((Array));
expect(response.items.length).toBeGreaterThanOrEqual(0);
});
test('Create a new IPNS record', async () => {
const name = 'Test IPNS';
const description = 'This is a test description';
const cid = 'QmUq4iFLKZUpEsHCAqfsBermXHRnPuE5CNcyPv1xaNkyGp';
const ipns = await storage.bucket(bucketUuid).createIpns({
name,
description,
cid,
});
expect(ipns).toBeDefined();
expect(ipns.name).toEqual(name);
expect(ipns.description).toEqual(description);
expect(ipns.ipnsValue).toEqual(`/ipfs/${cid}`);
newIpnsUuid = ipns.uuid; // Save the new IPNS UUID for later use in other tests
});
test('Get a specific IPNS record', async () => {
const ipns = await storage.bucket(bucketUuid).ipns(newIpnsUuid).get();
expect(ipns).toBeDefined();
expect(ipns.name).toEqual('Test IPNS');
expect(ipns.uuid).toEqual(newIpnsUuid);
});
test('Publish an IPNS record', async () => {
const cid = 'Qmakf2aN7wzt5u9H3RadGjfotu62JsDfBq8hHzGsV2LZFx';
const ipns = await storage
.bucket(bucketUuid)
.ipns(newIpnsUuid)
.publish(cid);
expect(ipns).toBeDefined();
expect(ipns.ipnsValue).toEqual(`/ipfs/${cid}`);
expect(ipns.uuid).toEqual(newIpnsUuid);
});
test('Delete an IPNS record', async () => {
const ipns = await storage.bucket(bucketUuid).ipns(newIpnsUuid).delete();
expect(ipns).toBeDefined();
expect(ipns.name).toEqual('Test IPNS');
expect(ipns.uuid).toEqual(newIpnsUuid);
});
});
//# sourceMappingURL=ipns.test.js.map