diff --git a/package.json b/package.json index 700401b108b29e..a6a9dffcc2b9ef 100755 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "scripts": { "start": "node app.js", - "test": "mocha tests/**/*.js" + "test": "mocha test/**/*.js" }, "dependencies": { "async": "~0.2.10", diff --git a/test/controllers/user_specs.js b/test/controllers/user_specs.js new file mode 100644 index 00000000000000..cbbc4d7942d971 --- /dev/null +++ b/test/controllers/user_specs.js @@ -0,0 +1,12 @@ +var request = require('supertest'); +var app = require('../../app.js'); + +describe('GET /', function() { + it('should return HTTP 200', function(done) { + request(app) + .get('/') + .expect(200, done); + }); +}); + + diff --git a/tests/models/User_spec.js b/test/models/User_spec.js similarity index 68% rename from tests/models/User_spec.js rename to test/models/User_spec.js index da735ed73ec535..ca44e5c9d93748 100644 --- a/tests/models/User_spec.js +++ b/test/models/User_spec.js @@ -2,34 +2,34 @@ process.env.NODE_ENV = 'test'; var User = require('../../models/User'); -var mocha = require('mocha') - , chai = require('chai') - , should = chai.should() - , expect = chai.expect - , mongoose = require('mongoose'); +var mocha = require('mocha'); +var chai = require('chai'); +var should = chai.should(); +var expect = chai.expect; +var mongoose = require('mongoose'); var user; describe('User attributes', function() { - before(function(done){ + before(function(done) { user = createUser(); done(); }); - + it('_id is a mongoDB ObjectId', function() { user._id.should.be.an.instanceOf(mongoose.Types.ObjectId); }); - + it('email should be a string', function() { - user.email.should.be.a( 'string' ); + user.email.should.be.a('string'); }); - + it('password should be a string', function() { - expect( user.password ).to.be.a( 'string' ); + expect(user.password).to.be.a('string'); }); }) -function createUser(){ +function createUser() { var user = new User({ email: getEmail(), password: '__password__', @@ -41,6 +41,6 @@ function createUser(){ // create unique email address // // TODO - use an implementation that guarantees string uniqueness -function getEmail(){ +function getEmail() { return new Date().getTime() + '@example.com'; } diff --git a/tests/controllers/user_specs.js b/tests/controllers/user_specs.js deleted file mode 100644 index f6e09fe516d97b..00000000000000 --- a/tests/controllers/user_specs.js +++ /dev/null @@ -1,16 +0,0 @@ -process.env.NODE_ENV = 'test'; - -var request = require('supertest') - , express = require('express') - , mocha = require('mocha') - , app = require('../../app.js'); - -describe('GET /', function(){ - it('should return HTTP 200', function(done){ - request(app) - .get('/') - .expect(200, done); - }); -}); - -