Skip to content

Commit 79f92d8

Browse files
committed
Initial set of Mocha tests.
1 parent b9bd429 commit 79f92d8

File tree

6 files changed

+57
-4
lines changed

6 files changed

+57
-4
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
SOURCES = lib/**/*.js
2-
TESTS ?= test/*-test.js test/**/*-test.js
2+
TESTS ?= test/*.test.js test/**/*.test.js
33

44
lint: lint-jshint
5-
test: test-vows
6-
test-cov: test-istanbul-vows
5+
test: test-mocha
6+
test-cov: test-istanbul-mocha
77
view-cov: view-istanbul-report
88

99

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
"oauth": "0.9.x"
3737
},
3838
"devDependencies": {
39-
"vows": "0.7.x"
39+
"vows": "0.7.x",
40+
"mocha": "1.x.x",
41+
"chai": "1.x.x",
42+
"chai-passport-strategy": "0.1.x"
4043
},
4144
"engines": { "node": ">= 0.4.0" },
4245
"scripts": {

test/bootstrap/node.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var chai = require('chai')
2+
, passport = require('chai-passport-strategy');
3+
4+
chai.use(passport);
5+
6+
7+
global.expect = chai.expect;

test/index-test.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var oauth = require('../');
66

77
vows.describe('passport-oauth').addBatch({
88

9+
// OK
910
'module': {
1011
'should export InternalOAuthError': function (x) {
1112
assert.isFunction(oauth.InternalOAuthError);

test/module.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var strategy = require('..');
2+
3+
describe('passport-oauth', function() {
4+
5+
it('should export Strategy constructors', function() {
6+
expect(strategy.OAuthStrategy).to.be.a('function');
7+
expect(strategy.OAuth2Strategy).to.be.a('function');
8+
});
9+
10+
it('should export Error constructors', function() {
11+
expect(strategy.InternalOAuthError).to.be.a('function');
12+
});
13+
14+
});

test/strategies/oauth2.test.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var OAuth2Strategy = require('../../lib/strategies/oauth2');
2+
3+
4+
describe('OAuth2Strategy', function() {
5+
6+
var strategy = new OAuth2Strategy({
7+
authorizationURL: 'https://www.example.com/oauth2/authorize',
8+
tokenURL: 'https://www.example.com/oauth2/token',
9+
clientID: 'ABC123',
10+
clientSecret: 'secret'
11+
}, function() {});
12+
13+
it('should be named oauth2', function() {
14+
expect(strategy.name).to.equal('oauth2');
15+
});
16+
17+
describe('constructed without a verify callback', function() {
18+
expect(function() {
19+
new OAuth2Strategy({
20+
authorizationURL: 'https://www.example.com/oauth2/authorize',
21+
tokenURL: 'https://www.example.com/oauth2/token',
22+
clientID: 'ABC123',
23+
clientSecret: 'secret'
24+
});
25+
}).to.throw(TypeError, 'passport-oauth.OAuth2Strategy requires a verify callback');
26+
});
27+
28+
});

0 commit comments

Comments
 (0)