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

Commit

Permalink
Make test descriptions more explicit. Use 'err' instead of 'e'.
Browse files Browse the repository at this point in the history
  • Loading branch information
haadcode committed Mar 23, 2017
1 parent 599020b commit 94d8bbc
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions test/pubsub-in-browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if (!isNode) {
describe('everything errors', () => {
describe('Callback API', () => {
describe('.publish', () => {
it('throws an error', (done) => {
it('throws an error if called in the browser', (done) => {
ipfs1.pubsub.publish(topic, 'hello friend', (err, topics) => {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
Expand All @@ -87,7 +87,7 @@ if (!isNode) {

describe('.subscribe', () => {
const handler = () => {}
it('throws an error', (done) => {
it('throws an error if called in the browser', (done) => {
ipfs1.pubsub.subscribe(topic, {}, handler, (err, topics) => {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
Expand All @@ -97,7 +97,7 @@ if (!isNode) {
})

describe('.peers', () => {
it('throws an error', (done) => {
it('throws an error if called in the browser', (done) => {
ipfs1.pubsub.peers(topic, (err, topics) => {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
Expand All @@ -107,7 +107,7 @@ if (!isNode) {
})

describe('.ls', () => {
it('throws an error', (done) => {
it('throws an error if called in the browser', (done) => {
ipfs1.pubsub.ls((err, topics) => {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
Expand All @@ -119,57 +119,57 @@ if (!isNode) {

describe('Promise API', () => {
describe('.publish', () => {
it('throws an error', () => {
it('throws an error if called in the browser', () => {
return ipfs1.pubsub.publish(topic, 'hello friend')
.catch((e) => {
expect(e).to.exist
expect(e.message).to.equal(expectedError)
.catch((err) => {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
})
})
})

describe('.subscribe', () => {
const handler = () => {}
it('throws an error', (done) => {
it('throws an error if called in the browser', (done) => {
ipfs1.pubsub.subscribe(topic, {}, handler)
.catch((e) => {
expect(e).to.exist
expect(e.message).to.equal(expectedError)
.catch((err) => {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
done()
})
})
})

describe('.peers', () => {
it('throws an error', (done) => {
it('throws an error if called in the browser', (done) => {
ipfs1.pubsub.peers(topic)
.catch((e) => {
expect(e).to.exist
expect(e.message).to.equal(expectedError)
.catch((err) => {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
done()
})
})
})

describe('.ls', () => {
it('throws an error', () => {
it('throws an error if called in the browser', () => {
return ipfs1.pubsub.ls()
.catch((e) => {
expect(e).to.exist
expect(e.message).to.equal(expectedError)
.catch((err) => {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
})
})
})
})

describe('.unsubscribe', () => {
it('throws an error', (done) => {
it('throws an error if called in the browser', (done) => {
try {
ipfs1.pubsub.unsubscribe(topic)
ipfs1.pubsub.unsubscribe()
done('unsubscribe() didn\'t throw an error')
} catch (e) {
expect(e).to.exist
expect(e.message).to.equal(expectedError)
} catch (err) {
expect(err).to.exist
expect(err.message).to.equal(expectedError)
done()
}
})
Expand Down

0 comments on commit 94d8bbc

Please sign in to comment.