Skip to content

Commit

Permalink
Fixed server-side test cases (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deon committed Feb 19, 2015
1 parent 6d3eb6a commit 5e12bcf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
2 changes: 0 additions & 2 deletions app/models/event.server.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ var EventSchema = new Schema({
},
datetime_start: {
type: Date,
default: Date.now,
required: 'Please enter a start date and time.'
},
datetime_end: {
type: Date,
default: Date.now,
required: 'Please enter a end date and time.'
},
location: {
Expand Down
12 changes: 8 additions & 4 deletions app/tests/event.server.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ describe('Event Model Unit Tests:', function() {
firstName: 'Full',
lastName: 'Name',
displayName: 'Full Name',
email: 'test@test.com',
email: 'test@uwaterloo.ca',
username: 'username',
password: 'password'
password: 'password',
verified: true
});

user.save(function() {
event = new Event({
name: 'Event Name',
user: user
user: user,
location: 'TBD',
datetime_start: '2016-02-03',
datetime_end: '2016-02-04'
});

done();
Expand Down Expand Up @@ -61,4 +65,4 @@ describe('Event Model Unit Tests:', function() {

done();
});
});
});
24 changes: 15 additions & 9 deletions app/tests/event.server.routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,22 @@ describe('Event CRUD tests', function() {
firstName: 'Full',
lastName: 'Name',
displayName: 'Full Name',
email: 'test@test.com',
email: 'test@uwaterloo.ca',
username: credentials.username,
password: credentials.password,
provider: 'local'
provider: 'local',
verified: true
});

// Save a user to the test db and create new Event
user.save(function() {
event = {
name: 'Event Name'
};
event = new Event ({
name: 'Event Name',
user: user,
location: 'TBD',
datetime_start: '2016-02-03',
datetime_end: '2016-02-04'
});

done();
});
Expand Down Expand Up @@ -75,7 +80,7 @@ describe('Event CRUD tests', function() {

// Set assertions
(events[0].user._id).should.equal(userId);
(events[0].name).should.match('Event Name');
(events[0].name).should.equal('Event Name');

// Call the assertion callback
done();
Expand Down Expand Up @@ -114,7 +119,7 @@ describe('Event CRUD tests', function() {
.expect(400)
.end(function(eventSaveErr, eventSaveRes) {
// Set message assertion
(eventSaveRes.body.message).should.match('Please fill Event name');
(eventSaveRes.body.message).should.match('Please enter a name for your event.');

// Handle Event save error
done(eventSaveErr);
Expand Down Expand Up @@ -170,9 +175,10 @@ describe('Event CRUD tests', function() {
// Save the Event
eventObj.save(function() {
// Request Events
request(app).get('/events')
request(app).get('/events/')
.end(function(req, res) {
// Set assertion
//console.log(res);
res.body.should.be.an.Array.with.lengthOf(1);

// Call the assertion callback
Expand Down Expand Up @@ -265,4 +271,4 @@ describe('Event CRUD tests', function() {
Event.remove().exec();
done();
});
});
});
6 changes: 3 additions & 3 deletions app/tests/user.server.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('User Model Unit Tests:', function() {
firstName: 'Full',
lastName: 'Name',
displayName: 'Full Name',
email: 'test@test.com',
email: 'test@uwaterloo.ca',
username: 'username',
password: 'password',
provider: 'local'
Expand All @@ -30,7 +30,7 @@ describe('User Model Unit Tests:', function() {
firstName: 'Full',
lastName: 'Name',
displayName: 'Full Name',
email: 'test@test.com',
email: 'test@uwaterloo.ca',
username: 'username',
password: 'password',
provider: 'local'
Expand Down Expand Up @@ -72,4 +72,4 @@ describe('User Model Unit Tests:', function() {
User.remove().exec();
done();
});
});
});

0 comments on commit 5e12bcf

Please sign in to comment.