Renamed tests folder to test
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node app.js",
|
"start": "node app.js",
|
||||||
"test": "mocha tests/**/*.js"
|
"test": "mocha test/**/*.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "~0.2.10",
|
"async": "~0.2.10",
|
||||||
|
12
test/controllers/user_specs.js
Normal file
12
test/controllers/user_specs.js
Normal file
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
@@ -2,34 +2,34 @@ process.env.NODE_ENV = 'test';
|
|||||||
|
|
||||||
var User = require('../../models/User');
|
var User = require('../../models/User');
|
||||||
|
|
||||||
var mocha = require('mocha')
|
var mocha = require('mocha');
|
||||||
, chai = require('chai')
|
var chai = require('chai');
|
||||||
, should = chai.should()
|
var should = chai.should();
|
||||||
, expect = chai.expect
|
var expect = chai.expect;
|
||||||
, mongoose = require('mongoose');
|
var mongoose = require('mongoose');
|
||||||
|
|
||||||
var user;
|
var user;
|
||||||
|
|
||||||
describe('User attributes', function() {
|
describe('User attributes', function() {
|
||||||
before(function(done){
|
before(function(done) {
|
||||||
user = createUser();
|
user = createUser();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('_id is a mongoDB ObjectId', function() {
|
it('_id is a mongoDB ObjectId', function() {
|
||||||
user._id.should.be.an.instanceOf(mongoose.Types.ObjectId);
|
user._id.should.be.an.instanceOf(mongoose.Types.ObjectId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('email should be a string', function() {
|
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() {
|
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({
|
var user = new User({
|
||||||
email: getEmail(),
|
email: getEmail(),
|
||||||
password: '__password__',
|
password: '__password__',
|
||||||
@@ -41,6 +41,6 @@ function createUser(){
|
|||||||
// create unique email address
|
// create unique email address
|
||||||
//
|
//
|
||||||
// TODO - use an implementation that guarantees string uniqueness
|
// TODO - use an implementation that guarantees string uniqueness
|
||||||
function getEmail(){
|
function getEmail() {
|
||||||
return new Date().getTime() + '@example.com';
|
return new Date().getTime() + '@example.com';
|
||||||
}
|
}
|
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user