diff --git a/README b/README index 9115aa1..1c4beac 100644 --- a/README +++ b/README @@ -9,7 +9,7 @@ $ ./runserver where port is a positive integer > 1023. To run the server on a different environment, use -$ node js/dispatcher.js +$ node js/dispatcher.js To interact with the server with your internet browser, browse host:port where host is the hostname of the machine you are running the server diff --git a/src/js/createDatabase.js b/src/js/createDatabase.js index 18a23ec..d5e8fa7 100755 --- a/src/js/createDatabase.js +++ b/src/js/createDatabase.js @@ -89,7 +89,7 @@ db.open(dbLocation, function (error) { console.log("comment table created."); }); - + }); diff --git a/src/node_modules/SQLiteHelper.js b/src/node_modules/SQLiteHelper.js index bc9c6ba..cd61826 100644 --- a/src/node_modules/SQLiteHelper.js +++ b/src/node_modules/SQLiteHelper.js @@ -292,6 +292,16 @@ module.exports.removeUser = function (userEmail, callback) { queryGetRows("DELETE FROM user WHERE email = ?", callback, [userEmail]); }; +/** + Parameter1: taskid of the comments which need to be removed. (String) + Parameter2: callback. (function) + + removes the comments corresponding to the given taskid if it exists. +*/ +module.exports.removeComments = function (commentsTaskid, callback) { + queryGetRows("DELETE FROM user WHERE taskid = ?", callback, [commentsTaskid]); +}; + /** Parameter1: a comment. (String) Parameter2: the taskid that the comment refers to. (String) diff --git a/src/static/index.html b/src/static/index.html index cf03d91..b3e1739 100644 --- a/src/static/index.html +++ b/src/static/index.html @@ -27,6 +27,7 @@

This is a placeholder for the main page

Add Task page

+

Example dynamic page request, using jquery

diff --git a/src/tests/comments/commentstest_nodeunit.js b/src/tests/comments/commentstest_nodeunit.js new file mode 100644 index 0000000..4d48dc6 --- /dev/null +++ b/src/tests/comments/commentstest_nodeunit.js @@ -0,0 +1,43 @@ +var path = require('path'); +var fs = require('fs'); +var basepath = require('basepath').mainpath; +var sqlite = require(basepath + 'lib/node-sqlite/sqlite'); +var slh = require('SQLiteHelper'); +var dbLocation = (basepath + 'db/main.db'); +var task = require('task'); + + +exports.CommentsTest = { + 'Test That Comments Can Be Added': function (test) { + test.expect(1); + + var succeeded = false; + + slh.addComment("testcomment", commentsTaskid, "test@test.com", + function (rtv) { + if (rtv.status == 0) { + succeeded = true; + + } + + test.ok(succeeded, "Adding comments failed!"); + test.done(); + }); + }, + + 'Test That Comments Can Be Removed': function (test) { + test.expect(1); + + var succeeded = false; + slh.removeComments(commentsTaskid, + function (rtv) { + if (rtv.status == 0) { + succeeded = true; + + } + + test.ok(succeeded, "Removing comments failed!"); + test.done(); + }); + }, +}; \ No newline at end of file diff --git a/src/tests/comments/commentstest_nodeunit.sh b/src/tests/comments/commentstest_nodeunit.sh new file mode 100644 index 0000000..b18e118 --- /dev/null +++ b/src/tests/comments/commentstest_nodeunit.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +cd .. +cd .. +node js/createDatabase.js + +node tests/nodeunit/bin/nodeunit tests/comments/commentstest_nodeunit.js +