Skip to content

Commit

Permalink
chore: getSubscribers (#32)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: getPeersSubscribed renamed to getSubscribers to remove redundant wording
  • Loading branch information
vasco-santos committed Dec 1, 2019
1 parent 1574023 commit b76451e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class PubsubBaseProtocol extends EventEmitter {
* @param {string} topic
* @returns {Array<string>}
*/
getPeersSubscribed (topic) {
getSubscribers (topic) {
if (!this.started) {
throw errcode(new Error('not started yet'), 'ERR_NOT_STARTED_YET')
}
Expand Down
10 changes: 5 additions & 5 deletions test/pubsub.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('pubsub base protocol', () => {
})
})

describe('getPeersSubscribed', () => {
describe('getSubscribers', () => {
let peerInfo
let pubsub

Expand All @@ -236,7 +236,7 @@ describe('pubsub base protocol', () => {
const topic = 'topic-test'

try {
pubsub.getPeersSubscribed(topic)
pubsub.getSubscribers(topic)
} catch (err) {
expect(err).to.exist()
expect(err.code).to.eql('ERR_NOT_STARTED_YET')
Expand All @@ -250,7 +250,7 @@ describe('pubsub base protocol', () => {
await pubsub.start()

try {
pubsub.getPeersSubscribed()
pubsub.getSubscribers()
} catch (err) {
expect(err).to.exist()
expect(err.code).to.eql('ERR_NOT_VALID_TOPIC')
Expand All @@ -265,7 +265,7 @@ describe('pubsub base protocol', () => {
// start pubsub
await pubsub.start()

let peersSubscribed = pubsub.getPeersSubscribed(topic)
let peersSubscribed = pubsub.getSubscribers(topic)
expect(peersSubscribed).to.be.empty()

// Set mock peer subscribed
Expand All @@ -275,7 +275,7 @@ describe('pubsub base protocol', () => {
peer.topics.add(topic)
pubsub.peers.set(id, peer)

peersSubscribed = pubsub.getPeersSubscribed(topic)
peersSubscribed = pubsub.getSubscribers(topic)

expect(peersSubscribed).to.not.be.empty()
expect(peersSubscribed[0]).to.eql(id)
Expand Down

0 comments on commit b76451e

Please sign in to comment.