This repository was archived by the owner on Feb 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathipfs.spec.js
More file actions
66 lines (54 loc) · 1.75 KB
/
ipfs.spec.js
File metadata and controls
66 lines (54 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const element = require('../../../index');
const config = require('../json/config.local.json');
const testObj = {
hello: 'world',
};
const testString = 'string';
const testInteger = 1;
describe('storage.ipfs', () => {
let storage;
beforeAll(() => {
storage = element.storage.ipfs.configure({
multiaddr: config.ipfsApiMultiAddr,
});
});
describe('configure', () => {
it('should configure and return a storage interface', async () => {
expect(storage.ipfs).toBeDefined();
});
});
describe('write', () => {
it('should write a JSON and return content id', async () => {
const cid = await storage.write(testObj);
expect(cid).toBe('QmNrEidQrAbxx3FzxNt9E6qjEDZrtvzxUVh47BXm55Zuen');
});
it('should write a string and return content id', async () => {
const cid = await storage.write(testString);
expect(cid).toBe('QmT2PFvRp4VXeBtFRWJUfJpssK6UqTZ5eHpaYQNcEXfNn8');
});
it('should write an integer and return content id', async () => {
const cid = await storage.write(testInteger);
expect(cid).toBe('QmWYddCPs7uR9EvHNCZzpguVFVNfHc6aM3hPVzPdAEESMc');
});
});
describe('read', () => {
it('should read a JSON', async () => {
const obj = await storage.read(
'QmNrEidQrAbxx3FzxNt9E6qjEDZrtvzxUVh47BXm55Zuen'
);
expect(obj).toEqual(testObj);
});
it('should read a string', async () => {
const obj = await storage.read(
'QmT2PFvRp4VXeBtFRWJUfJpssK6UqTZ5eHpaYQNcEXfNn8'
);
expect(obj).toEqual(testString);
});
it('should read an integer', async () => {
const obj = await storage.read(
'QmWYddCPs7uR9EvHNCZzpguVFVNfHc6aM3hPVzPdAEESMc'
);
expect(obj).toEqual(testInteger);
});
});
});