Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
feat: add goOffline method
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed May 6, 2016
1 parent 00be067 commit e15b828
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = class BlockService {
this._bitswap = bitswap
}

goOffline () {
this._bitswap = null
}

isOnline () {
return this._bitswap != null
}
Expand Down
8 changes: 8 additions & 0 deletions test/block-service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit e15b828

Please sign in to comment.