forked from ipfs/helia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.spec.ts
42 lines (34 loc) · 968 Bytes
/
get.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
37
38
39
40
41
42
/* 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'
import type { CID } from 'multiformats/cid'
describe('get', () => {
let blockstore: Blockstore
let d: DAGCBOR
let cid: CID
beforeEach(async () => {
blockstore = new MemoryBlockstore()
d = dagCbor({ blockstore })
cid = await d.add({
hello: 'world'
})
})
it('gets an object', async () => {
const result = await d.get(cid)
expect(result).to.deep.equal({
hello: 'world'
})
})
it('gets an object with a non-default hashing algorithm', async () => {
const input = {
hello: 'world'
}
const cid = await d.add(input, {
hasher: identity
})
await expect(d.get(cid)).to.eventually.deep.equal(input)
})
})