|
| 1 | +/* eslint-env mocha */ |
| 2 | +/* globals apiClients */ |
| 3 | +'use strict' |
| 4 | + |
| 5 | +const expect = require('chai').expect |
| 6 | + |
| 7 | +describe('.bitswap', () => { |
| 8 | + it('.wantlist', (done) => { |
| 9 | + apiClients.a.bitswap.wantlist((err, res) => { |
| 10 | + expect(err).to.not.exist |
| 11 | + expect(res).to.have.to.be.eql({ |
| 12 | + Keys: null |
| 13 | + }) |
| 14 | + done() |
| 15 | + }) |
| 16 | + }) |
| 17 | + |
| 18 | + it('.stat', (done) => { |
| 19 | + apiClients.a.bitswap.stat((err, res) => { |
| 20 | + expect(err).to.not.exist |
| 21 | + expect(res).to.have.property('BlocksReceived') |
| 22 | + expect(res).to.have.property('DupBlksReceived') |
| 23 | + expect(res).to.have.property('DupDataReceived') |
| 24 | + expect(res).to.have.property('Peers') |
| 25 | + expect(res).to.have.property('ProvideBufLen') |
| 26 | + expect(res).to.have.property('Wantlist') |
| 27 | + |
| 28 | + done() |
| 29 | + }) |
| 30 | + }) |
| 31 | + |
| 32 | + it('.unwant', (done) => { |
| 33 | + const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' |
| 34 | + apiClients.a.bitswap.unwant(key, (err) => { |
| 35 | + expect(err).to.not.exist |
| 36 | + done() |
| 37 | + }) |
| 38 | + }) |
| 39 | + |
| 40 | + describe('promise', () => { |
| 41 | + it('.wantlist', () => { |
| 42 | + return apiClients.a.bitswap.wantlist() |
| 43 | + .then((res) => { |
| 44 | + expect(res).to.have.to.be.eql({ |
| 45 | + Keys: null |
| 46 | + }) |
| 47 | + }) |
| 48 | + }) |
| 49 | + |
| 50 | + it('.stat', () => { |
| 51 | + return apiClients.a.bitswap.stat() |
| 52 | + .then((res) => { |
| 53 | + expect(res).to.have.property('BlocksReceived') |
| 54 | + expect(res).to.have.property('DupBlksReceived') |
| 55 | + expect(res).to.have.property('DupDataReceived') |
| 56 | + expect(res).to.have.property('Peers') |
| 57 | + expect(res).to.have.property('ProvideBufLen') |
| 58 | + expect(res).to.have.property('Wantlist') |
| 59 | + }) |
| 60 | + }) |
| 61 | + |
| 62 | + it('.unwant', () => { |
| 63 | + const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' |
| 64 | + return apiClients.a.bitswap.unwant(key) |
| 65 | + }) |
| 66 | + }) |
| 67 | +}) |
0 commit comments