forked from ipfs/helia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd.spec.ts
36 lines (28 loc) · 887 Bytes
/
add.spec.ts
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
/* eslint-env mocha */
import { expect } from 'aegir/chai'
import { MemoryBlockstore } from 'blockstore-core'
import { identity } from 'multiformats/hashes/identity'
import { dagCbor, type DAGCBOR } from '../src/index.js'
import type { Blockstore } from 'interface-blockstore'
describe('put', () => {
let blockstore: Blockstore
let d: DAGCBOR
beforeEach(async () => {
blockstore = new MemoryBlockstore()
d = dagCbor({ blockstore })
})
it('adds an object', async () => {
const cid = await d.add({
hello: 'world'
})
expect(`${cid}`).to.equal('bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae')
})
it('adds an object with a non-default hashing algorithm', async () => {
const cid = await d.add({
hello: 'world'
}, {
hasher: identity
})
expect(`${cid}`).to.equal('bafyqadnbmvugk3dmn5sxo33snrsa')
})
})