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

testing(): add object.get tests for multihash string #139

Merged
merged 3 commits into from
May 11, 2017
Merged
Changes from 1 commit
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
19 changes: 15 additions & 4 deletions src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ module.exports = (common) => {
cb()
})
},
(cb) => {
// get object from ipfs multihash string
ipfs.object.get(node1.toJSON().multihash, (err, node) => {
expect(err).to.not.exist()
expect(node).to.exist()
cb()
})
},
(cb) => {
expect(node1.data).to.eql(node2.data)
expect(node1.links).to.eql(node2.links)
Expand Down Expand Up @@ -781,14 +789,14 @@ module.exports = (common) => {
})
})

it('object.get', (done) => {
it('object.get', () => {
const testObj = {
Data: new Buffer('get test object'),
Links: []
}

ipfs.object.put(testObj).then((node1) => {
ipfs.object.get(node1.multihash).then((node2) => {
return ipfs.object.put(testObj).then((node1) => {
return ipfs.object.get(node1.multihash).then((node2) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenshyx all of these tests are written to test the callback API. Check at the bottom the section to test de promises API.

We always test in depth through the Callback API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, those lines are under promise API :)

// because js-ipfs-api can't infer if the
// returned Data is Buffer or String
if (typeof node2.data === 'string') {
Expand All @@ -797,7 +805,10 @@ module.exports = (common) => {

expect(node1.data).to.deep.equal(node2.data)
expect(node1.links).to.deep.equal(node2.links)
done()
// get object from ipfs multihash string
return ipfs.object.get(node1.toJSON().multihash).then((node2) => {
expect(node2).to.exist()
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a separate test.

})
})
})
Expand Down