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

test(ls): Add tests #195

Merged
merged 1 commit into from
Jan 22, 2016
Merged
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
36 changes: 36 additions & 0 deletions test/api/ls.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict'

const isNode = !global.window

describe('ls', function () {
it('should correctly retrieve links', function (done) {
if (!isNode) return done()

apiClients['a'].ls('QmSzLpCVbWnEm3XoTWnv6DT6Ju5BsVoLhzvxKXZeQ2cmdg', (err, res) => {
expect(err).to.not.exist

expect(res).to.have.a.property('Objects')
expect(res.Objects[0]).to.have.a.property('Links')
expect(res.Objects[0]).to.have.property('Hash', 'QmSzLpCVbWnEm3XoTWnv6DT6Ju5BsVoLhzvxKXZeQ2cmdg')
done()
})
})

it('should correctly handle a nonexisting hash', function (done) {
apiClients['a'].ls('surelynotavalidhashheh?', (err, res) => {
expect(err).to.exist
expect(res).to.not.exist
done()
})
})

it('should correctly handle a nonexisting path', function (done) {
if (!isNode) return done()

apiClients['a'].ls('QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj/folder_that_isnt_there', (err, res) => {
expect(err).to.exist
expect(res).to.not.exist
done()
})
})
})