Permalink
Browse files

Test cases for Twitter strategy.

  • Loading branch information...
1 parent 93d5769 commit 8322878010db772de0c7f42578cae19c09deff14 @jaredhanson jaredhanson committed Oct 17, 2011
Showing with 77 additions and 1 deletion.
  1. +1 −1 Makefile
  2. +15 −0 test/index-test.js
  3. +61 −0 test/strategy-test.js
View
@@ -1,6 +1,6 @@
NODE = node
TEST = vows
-TESTS ?= test/*-test.js test/**/*-test.js
+TESTS ?= test/*-test.js
test:
@NODE_ENV=test NODE_PATH=lib $(TEST) $(TEST_FLAGS) $(TESTS)
View
@@ -0,0 +1,15 @@
+var vows = require('vows');
+var assert = require('assert');
+var util = require('util');
+var twitter = require('passport-twitter');
+
+
+vows.describe('passport-twitter').addBatch({
+
+ 'module': {
+ 'should report a version': function (x) {
+ assert.isString(twitter.version);
+ },
+ },
+
+}).export(module);
View
@@ -0,0 +1,61 @@
+var vows = require('vows');
+var assert = require('assert');
+var util = require('util');
+var TwitterStrategy = require('passport-twitter/strategy');
+
+
+vows.describe('TwitterStrategy').addBatch({
+
+ 'strategy': {
+ topic: function() {
+ return new TwitterStrategy({
+ consumerKey: 'ABC123',
+ consumerSecret: 'secret'
+ },
+ function() {});
+ },
+
+ 'should be named twitter': function (strategy) {
+ assert.equal(strategy.name, 'twitter');
+ },
+ },
+
+ 'strategy handling a request that has been denied': {
+ topic: function() {
+ var strategy = new TwitterStrategy({
+ consumerKey: 'ABC123',
+ consumerSecret: 'secret'
+ },
+ function() {}
+ );
+ return strategy;
+ },
+
+ 'after augmenting with actions': {
+ topic: function(strategy) {
+ var self = this;
+ var req = {};
+ strategy.success = function(user) {
+ self.callback(new Error('should-not-be-called'));
+ }
+ strategy.fail = function() {
+ self.callback(null, req);
+ }
+
+ req.query = {};
+ req.query.denied = 'token';
+ process.nextTick(function () {
+ strategy.authenticate(req);
+ });
+ },
+
+ 'should not call success' : function(err, req) {
+ assert.isNull(err);
+ },
+ 'should call fail' : function(err, req) {
+ assert.isNotNull(req);
+ },
+ },
+ },
+
+}).export(module);

0 comments on commit 8322878

Please sign in to comment.