Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added unit tests

  • Loading branch information...
commit 349da1155893a1509524c2d08f150088db0b90c4 1 parent 9ac580a
@hakovala authored
Showing with 40 additions and 4 deletions.
  1. +5 −2 Makefile
  2. +0 −1  lib/trakt.js
  3. +35 −1 test/testTrakt.js
View
7 Makefile
@@ -9,8 +9,11 @@ test-w:
--watch
test-cov:
- @rm -r lib-cov
+ @rm -rf lib-cov
@jscoverage lib lib-cov
@TEST_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html
-.PHONY: test test-w
+clean:
+ @rm -rf lib-cov coverage.html
+
+.PHONY: test test-w clean
View
1  lib/trakt.js
@@ -142,7 +142,6 @@ var getPostParams = function(action, opts, options) {
if (options[param.name]) {
result[param.name] = options[param.name]
} else if(!param.optional) {
- console.log('wtf');
return undefined
}
}
View
36 test/testTrakt.js
@@ -61,6 +61,17 @@ describe('Trakt requests', function() {
res.should.includeEql({title: "hello"})
})
})
+ it('should discard extra optional arguments', function() {
+ var get = nock(url)
+ .get('/activity/shows.json/' + config.api_key + '/title')
+ .reply(200, {status: 'success'})
+ trakt.request('activity', 'shows', {title: 'title', start_ts: '12345678'}, function(err, res) {
+ should.not.exist(err)
+ should.exist(res)
+ res.should.have.property('status')
+ res.status.should.equal('success')
+ })
+ })
})
describe('Post request', function() {
it('should give error, no auth', function() {
@@ -96,5 +107,28 @@ describe('Trakt requests', function() {
res.message.should.equal('all good!')
})
})
+ it('should discard extra arguments', function() {
+ var post = nock(url)
+ .post('/show/library/' + config.api_key, {
+ tvdb_id: 'tvdb',
+ title: 'title',
+ year: 2000,
+ username: config.user,
+ password: config.pass
+ })
+ .reply(200, {status: 'success'})
+
+ trakt.request('show', 'library', {dummy: 'dummy', title: 'title', year: 2000}, function(err, res) {
+ should.exist(err)
+ err.message.should.equal('Missing parameters')
+ })
+
+ trakt.request('show', 'library', {tvdb_id: 'tvdb', dummy: 'dummy', title: 'title', year: 2000}, function(err, res) {
+ should.not.exist(err)
+ should.exist(res)
+ res.should.have.property('status')
+ res.status.should.equal('success')
+ })
+ })
})
-})
+})
Please sign in to comment.
Something went wrong with that request. Please try again.