diff options
| -rw-r--r-- | node_simple.js | 2 | ||||
| -rw-r--r-- | routes/index.js | 4 | ||||
| -rw-r--r-- | test/data/exam.json | 28 | ||||
| -rw-r--r-- | test/test.js | 51 | ||||
| -rw-r--r-- | views/user_solutions.hbs | 4 |
5 files changed, 61 insertions, 28 deletions
diff --git a/node_simple.js b/node_simple.js index dced853..1260c40 100644 --- a/node_simple.js +++ b/node_simple.js @@ -793,8 +793,6 @@ exports.get_all_solutions = function (exam_id, q_num, callback) { } }); - - }) .catch(function () { console.error(err); diff --git a/routes/index.js b/routes/index.js index 54bf058..f8292fc 100644 --- a/routes/index.js +++ b/routes/index.js @@ -241,10 +241,6 @@ router.get('/solutions/:exam_id/:q_num', function (req, res) { }); }); -router.post('/add_solutions/submit', function (req, res) { - //TODO: get the form information for the solutions -}); - /**** Helpers ****/ function addFirstAdmin() { diff --git a/test/data/exam.json b/test/data/exam.json index 0504679..ac9c0dc 100644 --- a/test/data/exam.json +++ b/test/data/exam.json @@ -1,32 +1,30 @@ { "existing" : { "_id": { - "$oid": "57917d4d2a73c0224fb6e763" + "$oid": "578a429640e1bf7e118a6b7b" }, - "course_code": "CSC373", - "year": "2016", - "term": "Midterm", - "type": "Winter", + "course_code": "CSC148", + "year": 2010, + "term": "fall", + "type": "midterm", "instructors": [ - "Robert Dane" + "Faith Ellen", + "Tom F." ], - "page_count": "20", - "questions_count": "2", + "page_count": 20, + "questions_count": 2, "questions_list": [ { "q_id": 1, - "question": "Question 1" + "question": "this is q1" }, { "q_id": 2, - "question": "Question 2" + "question": "this is q2" } ], - "upload_date": "2005-06-10", - "uploaded_by": [ - "humair", - "" - ] + "upload_date": "some date", + "uploaded_by": "some user name" }, "nonExisting" : { "_id": { diff --git a/test/test.js b/test/test.js index dd47d48..2105f02 100644 --- a/test/test.js +++ b/test/test.js @@ -8,8 +8,8 @@ var fs = require('fs'); // Database info, cross check with database docs to ensure these files either: -// a) exist -// b) do not exist +// We test get requests here mostly as those are the core functions of the +// website that do not alter the database. var examPull = fs.readFileSync("test/data/exam.json"); var exams = (JSON.parse(examPull)); @@ -19,8 +19,6 @@ var users = (JSON.parse(usersPull)); chai.use(chaiHttp); -var request = require('supertest'); - /* Test simple routes that do not require database queries */ describe('Test Simple Route:', function () { @@ -247,7 +245,7 @@ describe('Questions Search Route:', function(){ * query and not return an exam at all, whereas before we pass in a * legitimate hashed format id. Here we pass just random letters. */ - it.only('Search questions for gibberish id', function testSlash(done) { + it('Search questions for gibberish id', function testSlash(done) { chai.request(server) .get('/questions/batman') .end(function(err, res){ @@ -263,3 +261,46 @@ describe('Questions Search Route:', function(){ }); +/* Solutions listing for a particular exam question +* Pre-condition: Assume existing exam in db has at least question 1*/ +describe('Solutions Route:', function(){ + var server; + before(function () { + server = require('./test_server'); + }); + after(function () { + server.close(); + }); + + + it('Search solutions for an existing exam', function testSlash(done) { + var qID = 1; //Check the first question + var examID = exams.existing._id.$oid; + chai.request(server) + .get('/solutions/' + examID + '/' + qID) + .end(function(err, res){ + expect(res).to.have.status(200); + // Check for expected url path + var path = res.res.req.path; + assert.equal(path, '/solutions/' + examID + '/' + qID); + done(); + }); + }); + + it.only('Search solutions for a non existing exam', function testSlash(done) { + var qID = 1; //Check the first question + var examID = exams.nonExisting._id.$oid; + chai.request(server) + .get('/solutions/' + examID + '/' + qID) + .end(function(err, res){ + expect(res).to.have.status(200); + // Check for expected url path + var path = res.res.req.path; + assert.equal(path, '/solutions/' + examID + '/' + qID); + done(); + }); + }); + + +}); + diff --git a/views/user_solutions.hbs b/views/user_solutions.hbs index fac0301..f50499f 100644 --- a/views/user_solutions.hbs +++ b/views/user_solutions.hbs @@ -26,9 +26,9 @@ </a> <!-- Replace p below with breadcrumbs later --> - <p class="col-xs-12 col-sm-12 col-md-6 show-path"> + <!--<p class="col-xs-12 col-sm-12 col-md-6 show-path"> CSC148 > Winter 2015 > Question 1 - </p> + </p> --> </div> <!-- Solution 1 Example --> |
