Permalink
Browse files

Port test cases to mocha.

  • Loading branch information...
1 parent d0c6b3f commit b113e805c6fa47457878ef4224c8442f048b8427 @jaredhanson committed Mar 9, 2014
Showing with 71 additions and 0 deletions.
  1. +4 −0 test/strategy-test.js
  2. +67 −0 test/strategy.test.js
View
@@ -6,6 +6,7 @@ var GitHubStrategy = require('../lib/strategy');
vows.describe('GitHubStrategy').addBatch({
+ // OK
'strategy': {
topic: function() {
return new GitHubStrategy({
@@ -23,6 +24,7 @@ vows.describe('GitHubStrategy').addBatch({
},
},
+ // OK
'strategy with user agent option': {
topic: function() {
return new GitHubStrategy({
@@ -38,6 +40,7 @@ vows.describe('GitHubStrategy').addBatch({
},
},
+ // OK
'strategy with user agent option in custom headers': {
topic: function() {
return new GitHubStrategy({
@@ -53,6 +56,7 @@ vows.describe('GitHubStrategy').addBatch({
},
},
+ // OK
'strategy with user agent option in custom headers and explicit option': {
topic: function() {
return new GitHubStrategy({
View
@@ -0,0 +1,67 @@
+/* global describe, it, expect */
+/* jshint expr: true */
+
+var GitHubStrategy = require('../lib/strategy');
+
+
+describe('Strategy', function() {
+
+ var strategy = new GitHubStrategy({
+ clientID: 'ABC123',
+ clientSecret: 'secret'
+ },
+ function() {});
+
+ it('should be named github', function() {
+ expect(strategy.name).to.equal('github');
+ });
+
+ it('should have default user agent', function() {
+ expect(strategy._oauth2._customHeaders['User-Agent']).to.equal('passport-github');
+ });
+
+
+ describe('constructed with user agent option', function() {
+
+ var strategy = new GitHubStrategy({
+ clientID: 'ABC123',
+ clientSecret: 'secret',
+ userAgent: 'example.com'
+ },
+ function() {});
+
+ it('should have default user agent', function() {
+ expect(strategy._oauth2._customHeaders['User-Agent']).to.equal('example.com');
+ });
+ });
+
+ describe('constructed with custom headers including user agent', function() {
+
+ var strategy = new GitHubStrategy({
+ clientID: 'ABC123',
+ clientSecret: 'secret',
+ customHeaders: { 'User-Agent': 'example.net' }
+ },
+ function() {});
+
+ it('should have default user agent', function() {
+ expect(strategy._oauth2._customHeaders['User-Agent']).to.equal('example.net');
+ });
+ });
+
+ describe('constructed with both custom headers including user agent and user agent option', function() {
+
+ var strategy = new GitHubStrategy({
+ clientID: 'ABC123',
+ clientSecret: 'secret',
+ customHeaders: { 'User-Agent': 'example.org' },
+ userAgent: 'example.net'
+ },
+ function() {});
+
+ it('should have default user agent', function() {
+ expect(strategy._oauth2._customHeaders['User-Agent']).to.equal('example.org');
+ });
+ });
+
+});

0 comments on commit b113e80

Please sign in to comment.