Browse files

testing with mocha, delete not passing

  • Loading branch information...
1 parent b10c62d commit e82b827e2365864bbd29cd6db6c6d577985d8410 @yesobo committed Dec 11, 2012
Showing with 29 additions and 21 deletions.
  1. +5 −1 README.md
  2. +2 −2 app.coffee
  3. +3 −14 app.js
  4. +1 −1 routes.coffee
  5. +2 −2 routes.js
  6. +16 −1 test/mocha_api_test.js
View
6 README.md
@@ -6,7 +6,11 @@ TODO:
- (in process) Apply the daos branch purposes on master branch.
- (in process) convert database and routes files in one routes file and multiple dao files.
- - pass all mocha_api_test.js tests.
+ - pass all mocha_api_test.js tests. (delete is failing)
+ - improve the tests at mocha_api_test.js. They are almost only checking the return code.
+ - convert database.coffee/js, routesSequelize.coffe/js and models.coffee/js on daos/SequelizeDao.coffe/js
+
+- organize files as: http://openmymind.net/NodeJS-Module-Exports-And-Organizing-Express-Routes/
- Test return error codes.
View
4 app.coffee
@@ -4,7 +4,7 @@ express = require 'express'
app = express()
# Set dao init path
#database = "./database.js"
-routes = "./routesMongoHQ.js"
+routes = "./routes.js"
###
app
@@ -73,4 +73,4 @@ app.get '/api', (req, res)=>
routes = require routes
# HTTP Server
app.listen port
-console.log "Express Server listening on port #{port} in #{app.settings.env} mode using Sequelize ORM."
+console.log "Express Server listening on port #{port} in #{app.settings.env} mode."
View
17 app.js
@@ -1,15 +1,13 @@
// Generated by CoffeeScript 1.3.3
(function() {
- var allowCrossDomain, app, args, database, database_options, express, port, routes,
+ var allowCrossDomain, app, args, database_options, express, port, routes,
_this = this;
express = require('express');
app = express();
- routes = "./routesMongoHQ.js";
-
- database = "./mongoHQdb.js";
+ routes = "./routes.js";
/*
app
@@ -81,19 +79,10 @@
return res.send('Ecomm API is running');
});
- /*
- db (database)
- @type {Object}
- @param Object [database_options] the database options
- */
-
-
- GLOBAL.db = require(database)(database_options);
-
routes = require(routes);
app.listen(port);
- console.log("Express Server listening on port " + port + " in " + app.settings.env + " mode using Sequelize ORM.");
+ console.log("Express Server listening on port " + port + " in " + app.settings.env + " mode.");
}).call(this);
View
2 routes.coffee
@@ -51,7 +51,7 @@ app.put '/api/patterns/:id', (req, res) ->
if err?
res.send 404
else
- daoObj.findById updated_pattern intId, (err, item) ->
+ daoObj.findById intId, (err, item) ->
res.send item
# DELETE delete product by id
View
4 routes.js
@@ -66,9 +66,9 @@
if (err != null) {
return res.send(404);
} else {
- return daoObj.findById(updated_pattern(intId, function(err, item) {
+ return daoObj.findById(intId, function(err, item) {
return res.send(item);
- }));
+ });
}
});
});
View
17 test/mocha_api_test.js
@@ -150,7 +150,7 @@ describe('Tests for patterns API, ', function() {
});
});
- describe.only('Insert new pattern with id = 3', function() {
+ describe('Insert new pattern with id = 3', function() {
it('should be succesful', function(done){
var post_options = {
method: 'POST',
@@ -200,4 +200,19 @@ describe('Tests for patterns API, ', function() {
request(post_options, put_callback);
});
});
+
+ describe('Delete pattern with id = 3 test', function() {
+ it('should be succesful', function(error, res, body) {
+ var post_options = {
+ method: 'DEL',
+ uri: url + '/api/patterns/3',
+ port: 8010
+ };
+ var del_callback = function(error, res, body) {
+ res.statusCode.should.be.equal(200);
+ done();
+ };
+ request(post_options, del_callback);
+ });
+ });
});

0 comments on commit e82b827

Please sign in to comment.