climb-social
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "climb-social", | ||
"version": "1.0.1", | ||
"description": "JS client library for Climb.social.", | ||
"version": "1.1.0", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"commit": "git-cz", | ||
"prebuild": "rm -rf dist && mkdir dist", | ||
"build": "babel src/index.js -o dist/index.js", | ||
"test": "mocha src/index.test.js -w --compilers js:babel/register" | ||
"test": "mocha src/index.test.js --compilers js:babel/register", | ||
"test:watch": "mocha src/index.test.js -w --compilers js:babel/register", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Climb-social/climb-social.git" | ||
"url": "https://github.com/Climb-social/climb-social.git" | ||
}, | ||
"keywords": [ | ||
"javascript", | ||
"RxJS", | ||
"climb.social" | ||
@@ -32,4 +36,13 @@ ], | ||
"chai": "^3.3.0", | ||
"mocha": "^2.3.3" | ||
"commitizen": "^1.0.5", | ||
"cz-conventional-changelog": "^1.1.2", | ||
"jsdom": "^6.5.1", | ||
"mocha": "^2.3.3", | ||
"mocha-jsdom": "^1.0.0", | ||
"nock": "^2.15.0", | ||
"semantic-release": "^4.3.5" | ||
}, | ||
"czConfig": { | ||
"path": "node_modules/cz-conventional-changelog" | ||
} | ||
} | ||
} |
# Climb.social | ||
[](https://travis-ci.org/Climb-social/climb-social) | ||
JS library for interacting with the [Climb.social](http://climb.social/) [API](http://docs.climbsocial.apiary.io/). | ||
@@ -3,0 +6,0 @@ |
import {Observable} from 'rx-lite'; | ||
import fetchJsonp from 'fetch-jsonp'; | ||
const getStream = (collectionId) => { | ||
const getStream = (collectionId, intervalSeconds = 8) => { | ||
const pollRate = 5 * 1000; | ||
if (!collectionId) { | ||
throw new Error('Please specify a collectionId'); | ||
} | ||
if (typeof(intervalSeconds) !== 'number') { | ||
throw new Error(`Polling interval should be a positive integer. A ${typeof(intervalSeconds)} was provided.`); | ||
} | ||
if (intervalSeconds <= 0) { | ||
throw new Error(`Polling interval should be a positive integer. ${intervalSeconds} was specified.`); | ||
} | ||
const pollRate = intervalSeconds * 1000; | ||
const requestStream = Observable.just(`http://app.climb.social/api/v1/collections/${collectionId}`); | ||
@@ -9,0 +21,0 @@ |
import climb from './index'; | ||
import {expect} from 'chai'; | ||
import nock from 'nock'; | ||
import jsdom from 'mocha-jsdom'; | ||
describe('Climb.social', () => { | ||
it('should work', () => { | ||
expect(true).to.be.true; | ||
const collectionId = "561ba63445284e1740e016f7"; | ||
describe('Climb.social library', () => { | ||
jsdom(); | ||
it('is defined', () => { | ||
expect(climb).to.be.a('object'); | ||
}); | ||
describe('getStream() method',() => { | ||
it('should exist', () => { | ||
expect(climb.getStream).to.be.a('function'); | ||
}); | ||
it('should error without a collectionId', () => { | ||
expect(() => { | ||
const subscription = climb.getStream(); | ||
}).to.throw("Please specify a collectionId"); | ||
}); | ||
it('should not error with a collectionId', () => { | ||
expect(() => { | ||
const stream = climb.getStream(collectionId); | ||
}).to.not.throw(); | ||
}); | ||
it('should accept an optional polling interval value', () => { | ||
expect(() => { | ||
const stream = climb.getStream(collectionId, 0.001); | ||
}).to.not.throw(); | ||
expect(() => { | ||
const stream = climb.getStream(collectionId, 5); | ||
}).to.not.throw(); | ||
expect(() => { | ||
const stream = climb.getStream(collectionId, 50000); | ||
}).to.not.throw(); | ||
}); | ||
it('should error with a negative polling value', () => { | ||
expect(() => { | ||
const stream = climb.getStream(collectionId, -200); | ||
}).to.throw(); | ||
expect(() => { | ||
const stream = climb.getStream(collectionId, 0); | ||
}).to.throw(); | ||
expect(() => { | ||
const stream = climb.getStream(collectionId, -0.00001); | ||
}).to.throw(); | ||
}); | ||
it('should error if interval length is not a interval', () => { | ||
expect(() => { | ||
const stream = climb.getStream(collectionId, '8'); | ||
}).to.throw(); | ||
}); | ||
it('should return an object with a `subscribe()` method (an Observable)', () => { | ||
const stream = climb.getStream(collectionId); | ||
expect(stream.subscribe).to.be.a('function') | ||
}); | ||
xit('should make HTTP requests to Climb.social', () => { | ||
}); | ||
}); | ||
}); |
9208
9
118
31
9