Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

test: pin.ls with multiple CIDs #563

Merged
merged 2 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions SPEC/PIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ A great source of [examples][] can be found in the tests for this API.

> List all the objects pinned to local storage or under a specific hash.

##### `ipfs.pin.ls([hash], [options])`
##### `ipfs.pin.ls([cid], [options])`

Where:

- `hash` is an IPFS multihash.
- `cid` - a [CID][cid] instance or CID as a string or an array of CIDs.
- `options` is an object that can contain the following keys:
- 'type' - Return also the type of pin (direct, indirect or recursive)

Expand Down Expand Up @@ -107,3 +107,4 @@ console.log(pinset)
A great source of [examples][] can be found in the tests for this API.

[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/pin
[cid]: https://www.npmjs.com/package/cids
7 changes: 7 additions & 0 deletions src/pin/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,12 @@ module.exports = (createCommon, options) => {
hash: fixtures.files[0].cid
}])
})

it('should list pins for multiple CIDs', async () => {
const pinset = await ipfs.pin.ls([fixtures.files[0].cid, fixtures.files[1].cid])
const cids = pinset.map(({ hash }) => hash)
expect(cids).to.include(fixtures.files[0].cid)
expect(cids).to.include(fixtures.files[1].cid)
})
})
}