diff --git a/src/index.js b/src/index.js index cda741a..f2d6ca5 100644 --- a/src/index.js +++ b/src/index.js @@ -15,6 +15,10 @@ module.exports = class BlockService { this._bitswap = bitswap } + goOffline () { + this._bitswap = null + } + isOnline () { return this._bitswap != null } diff --git a/test/block-service-test.js b/test/block-service-test.js index 3c4e991..63ea619 100644 --- a/test/block-service-test.js +++ b/test/block-service-test.js @@ -213,6 +213,14 @@ module.exports = (repo) => { }) }) }) + + it('goes offline', () => { + bs = new BlockService(repo) + bs.goOnline({}) + expect(bs.isOnline()).to.be.eql(true) + bs.goOffline() + expect(bs.isOnline()).to.be.eql(false) + }) }) describe('online', () => {