Skip to content

Commit

Permalink
added test sheclls
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniespratley committed Dec 11, 2014
1 parent 17c7689 commit ad7c06d
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 112 deletions.
11 changes: 11 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = function (grunt) {

//Connect proxy to route requests to localhost:8181/api
grunt.loadNpmTasks('grunt-connect-proxy');
grunt.loadNpmTasks('intern');
require('json-proxy').initialize({});
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
Expand Down Expand Up @@ -607,6 +608,16 @@ module.exports = function (grunt) {
'test/routes/*-spec.js'
]
}
},
intern: {
test: {
options: {
runType: 'client',
config: 'test/intern.conf',
reporters: [ 'console', 'pretty', 'lcov' ],
suites: []
}
}
}
};

Expand Down
28 changes: 16 additions & 12 deletions test/intern.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ define({
// OnDemand. Options that will be permutated are browserName, version, platform, and platformVersion; any other
// capabilities options specified for an environment will be copied as-is
environments: [
{ browserName: 'internet explorer', version: '11', platform: 'Windows 8.1' },
{ browserName: 'internet explorer', version: '10', platform: 'Windows 8' },
{ browserName: 'internet explorer', version: '9', platform: 'Windows 7' },
{ browserName: 'firefox', version: '28', platform: [ 'OS X 10.9', 'Windows 7', 'Linux' ] },
{ browserName: 'chrome', version: '34', platform: [ 'OS X 10.9', 'Windows 7', 'Linux' ] },
{ browserName: 'safari', version: '6', platform: 'OS X 10.8' },
{ browserName: 'safari', version: '7', platform: 'OS X 10.9' }
{browserName: 'chrome'}
],

// Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
Expand All @@ -50,28 +44,38 @@ define({
// loader
useLoader: {
'host-node': 'dojo/dojo',
'host-browser': 'node_modules/dojo/dojo.js'
'host-browser': 'node_modules/dojo/dojo.js',
'supertest': 'node_modules/supertest/index.js',
'request': 'node_modules/request/index.js'
},

// Configuration options for the module loader; any AMD configuration options supported by the specified AMD loader
// can be used here
loader: {
// Packages that should be registered with the loader in each testing environment
packages: [ { name: 'myPackage', location: '.' } ]
packages: [
{ name: 'myPackage', location: '.' }
]
},

// Non-functional test suite(s) to run in each browser
suites: [
'tests/hello'
'test/routes/cms-auth-spec',
'test/routes/cms-passport-spec',
'test/routes/cms-proxy-spec',
'test/routes/cms-rest-spec',
'test/routes/cms-server-spec',
'test/routes/cms-sockets-spec',
'test/routes/cms-upload-spec'
/* 'myPackage/tests/foo',
'myPackage/tests/bar' */
],

// Functional test suite(s) to run in each browser once non-functional tests are completed
functionalSuites: [
'tests/functional/index'
//'tests/functional/index'
/* 'myPackage/tests/functional' */ ],

// A regular expression matching URLs to files that should not be included in code coverage analysis
excludeInstrumentation: /^(?:tests|node_modules)\//
excludeInstrumentation: /^(?:tests|node_modules|app\/bower_components|www|config|bin)\//
});
33 changes: 18 additions & 15 deletions test/routes/cms-auth-spec.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@


describe('cms-auth', function(){
it('should have /auth/login route', function (done) {
//
done();
/* global define */
define([
'intern!object',
'intern/chai!assert',
'intern/dojo/node!request'
], function (registerSuite, assert, request) {
'use strict';
registerSuite({
name: 'cms-auth',
'should have /auth/login route': function () {
this.skip();
},
'should have /auth/register route': function () {
this.skip();
},
'should have /auth/me route': function () {
this.skip();
}
});
it('should have /auth/register route', function (done) {
//
done();
});
it('should have /auth/me route', function (done) {
//
done();
});

});
121 changes: 55 additions & 66 deletions test/routes/cms-passport-spec.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,62 @@
"use strict";
var request = require('supertest');
var path = require('path');
var fs = require('fs');
var expect = require('chai').expect;
var express = require('express');
var app = express();
var config = JSON.parse(fs.readFileSync(process.cwd() + '/config/config.json'));
config.port = 9191

var cmsPassport = require(process.cwd() + '/routes/cms-passport')(config, app);
describe('cms-passport', function () {

it('should have /account route', function (done) {
done();
});
it('should have /auth/login route', function (done) {
//
});

it('POST - /login - should return user on successful login', function (done) {
/* global define */
define([
'intern!object',
'intern/chai!expect',
'intern/dojo/node!path',
'intern/dojo/node!fs',
'intern/dojo/node!supertest',
'intern/dojo/node!express',
'intern/dojo/node!../../routes/cms-passport',
], function (registerSuite, expect, path, fs, request, express, cmsPassport) {
'use strict';


var app = express();
var config = JSON.parse(fs.readFileSync(process.cwd() + '/config/config.json'));
config.port = 9191

cmsPassport(config, app);


registerSuite({
name: 'cms-passport',
'should have /proxy route': function () {
},
'should have a /auth/google/callback route': function () {
},
'should have a /auth/google route': function () {
},
'should have /auth/me route': function () {
},
'should have /auth/register route': function () {
},
'POST - /register - should return user on successful registration': function () {
var dfd = this.async();
request(app)
.post('/register')
.send({
"username": Date.now() + "[email protected]",
"email": Date.now() + "[email protected]",
"password": "test",
"metadata": {
"avatar": "",
"name": "Jonnie Dollas"
}
})
.expect("Content-Type", /json/)
.expect(201, dfd.resolve);
},
'POST - /login - should return user on successful login': function () {
var dfd = this.async();
var validUser = {
username: '[email protected]',
password: 'test'
};
request(app)
.post('/login')
.send(validUser)
.expect("Content-Type", /json/)
.expect(200, done);
});


it('POST - /register - should return user on successful registation', function (done) {
request(app)
.post('/register')
.send({
"username": Date.now() + "[email protected]",
"email": Date.now() + "[email protected]",
"password": "test",
"metadata": {
"avatar": "",
"name": "Jonnie Dollas"
}
})
.expect("Content-Type", /json/)
.expect(201, done);
.post('/login')
.send(validUser)
.expect("Content-Type", /json/)
.expect(200, dfd.resolve);
}
});



it('should have /auth/register route', function (done) {
//
done();
});

it('should have /auth/me route', function (done) {
//
done();
});

describe('Google Auth', function () {
it('should have a /auth/google route', function (done) {
//
done();
});
it('should have a /auth/google/callback route', function (done) {
//
done();
});
});

});
14 changes: 14 additions & 0 deletions test/routes/cms-proxy-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* global define */
define([
'intern!object',
'intern/chai!assert',
'intern/dojo/node!request'
], function (registerSuite, assert, request) {
'use strict';
registerSuite({
name: 'cms-proxy',
'should have /proxy route': function () {
this.skip();
}
});
});
41 changes: 22 additions & 19 deletions test/routes/cms-rest-spec.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
describe('cms-rest', function () {
it('should have a /collection/:id route', function (done) {
//
done();
/* global define */
define([
'intern!object',
'intern/chai!assert',
'intern/dojo/node!request'
], function (registerSuite, assert, request) {
'use strict';
registerSuite({
name: 'cms-rest',
'GET - /collection - should return array of items': function () {
this.skip();
},
'GET - /collection/:id - should return object item': function () {
this.skip();
},
'POST - /collection - should return object on success': function () {
this.skip();
},
'PUT - /collection/:id - should return object on success': function () {
this.skip();
}
});
it('GET - /collection - should return array of items', function (done) {
done();
});
it('GET - /collection/:id - should return object item', function (done) {
//
done();
});
it('POST - /collection - should return object on success', function (done) {
//
done();
});
it('PUT - /collection/:id - should return object on success', function (done) {
done();
});
});
});
14 changes: 14 additions & 0 deletions test/routes/cms-server-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* global define */
define([
'intern!object',
'intern/chai!assert',
'intern/dojo/node!request'
], function (registerSuite, assert, request) {
'use strict';
registerSuite({
name: 'cms-server',
'should have /proxy route': function () {
this.skip();
}
});
});
14 changes: 14 additions & 0 deletions test/routes/cms-sockets-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* global define */
define([
'intern!object',
'intern/chai!assert',
'intern/dojo/node!request'
], function (registerSuite, assert, request) {
'use strict';
registerSuite({
name: 'cms-sockets',
'should have /proxy route': function () {
this.skip();
}
});
});
14 changes: 14 additions & 0 deletions test/routes/cms-upload-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* global define */
define([
'intern!object',
'intern/chai!assert',
'intern/dojo/node!request'
], function (registerSuite, assert, request) {
'use strict';
registerSuite({
name: 'cms-upload',
'should have /proxy route': function () {
this.skip();
}
});
});

0 comments on commit ad7c06d

Please sign in to comment.