Permalink
Browse files

Some more testing updates, setup the mongoose test file with test data

  • Loading branch information...
1 parent 7858338 commit b5e8cf9c7512a637a37330b0941956d08ebbac0b @astalker committed Mar 19, 2013
Showing with 45 additions and 14 deletions.
  1. +7 −0 lib/mongoose.js
  2. +4 −14 test/{main.js → helper.js}
  3. +34 −0 test/server.js
View
@@ -3,6 +3,8 @@ var moment = require('moment');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
+mongoose.connection.on('error', function() {});
+
/**
* Connect to the database.
*
@@ -71,6 +73,11 @@ var Pages = mongoose.model('Pages');
exports.emptyArticle = { "_id": "", title: "", article: "", alias: "", description: "", keywords: "" };
exports.emptyPage = { "_id": "", page: "", intro: "", content: "", description: "", keywords: "", menu: "", alias: "" };
+exports.remove = function(callback) {
+ Article.remove({}, function () { });
+ callback(null);
+}
+
/**
* Add a new article.
*
@@ -1,31 +1,21 @@
var should = require('should')
+ , db = require('../lib/mongoose')
, helper = require('../lib/helper')
- , nblog = require('../lib/nblog')
var params = {
config: {
project: 'My Project',
public: '/../public',
per_page: '1'
- },
- dev: {
- user: 'user',
- pass: 'password',
- port: '3000',
- db: 'mongodb://localhost/items'
- },
- prod: {
- user: 'user',
- pass: 'password',
- db: 'mongodb://localhost/articles'
- }
+ }
}
+db.connect('mongodb://localhost/test');
+
describe('helper', function(){
describe('#prefs()', function(){
it('should return a valid prefs object', function(done){
- nblog.init(params);
helper.prefs(params, function(pref){
pref.should.be.a('object');
pref.should.have.property('settings');
View
@@ -0,0 +1,34 @@
+
+var should = require('should')
+ , db = require('../lib/mongoose')
+ , helper = require('../lib/helper')
+
+var params = {
+ config: {
+ project: 'My Project',
+ public: '/../public',
+ per_page: '1'
+ }
+}
+
+db.connect('mongodb://localhost/test');
+
+describe('Articles', function(){
+
+ var currentArticle = null;
+
+ beforeEach(function(done){
+ //add some test data
+ db.add('test', '', 'article', 'description', 'keywords', 'alias', function(doc){
+ currentArticle = doc;
+ done();
+ });
+ });
+
+ afterEach(function(done){
+ db.remove(function() {
+ done();
+ });
+ });
+
+});

0 comments on commit b5e8cf9

Please sign in to comment.