-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
115 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
// Tests for use cases at the notes route | ||
var notes = require('../../models/notes'); | ||
var users = require('../../models/users'); | ||
var zombie = require('zombie'); | ||
var browser = new zombie(); | ||
|
||
// Empty the database | ||
exports['setup'] = function(test) { | ||
notes.deleteAll(function() { | ||
test.done(); | ||
}); | ||
}; | ||
|
||
exports['log in (success)'] = function(test) { | ||
test.expect(2); | ||
console.log('hello'); | ||
browser.visit('http://localhost:8082/', function() { | ||
test.ok(browser.query('#login')); | ||
console.log('hey'); | ||
browser. | ||
fill('#login_name', 'username'). | ||
fill('#login_password', 'password'). | ||
pressButton('#login_submit', function() { | ||
test.ok(browser.query('#logout')); | ||
browser.clickLink('#logout', function() { | ||
test.done(); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
// Empty the database and close the connection | ||
exports['cleanup'] = function(test) { | ||
notes.deleteAll(function() { | ||
notes.close(function() { | ||
test.done(); | ||
}); | ||
}); | ||
}; | ||
// Tests for use cases at the notes route | ||
var notes = require('../../models/notes'); | ||
var users = require('../../models/users'); | ||
var zombie = require('zombie'); | ||
var browser = new zombie(); | ||
|
||
// Empty the database | ||
exports['setup'] = function(test) { | ||
notes.deleteAll(function() { | ||
test.done(); | ||
}); | ||
}; | ||
|
||
exports['log in (success)'] = function(test) { | ||
test.expect(2); | ||
console.log('hello'); | ||
browser.visit('http://localhost:8082/', function() { | ||
test.ok(browser.query('#login')); | ||
console.log('hey'); | ||
browser. | ||
fill('#login_name', 'username'). | ||
fill('#login_password', 'password'). | ||
pressButton('#login_submit', function() { | ||
test.ok(browser.query('#logout')); | ||
browser.clickLink('#logout', function() { | ||
test.done(); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
// Empty the database and close the connection | ||
exports['cleanup'] = function(test) { | ||
notes.deleteAll(function() { | ||
notes.close(function() { | ||
test.done(); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,76 @@ | ||
// Skyler Ng | ||
// Unit tests for the users collections | ||
|
||
// This is to get to the database code in the folder models | ||
var users = require('../../models/users'); | ||
|
||
// Before testing user collection, we want to put it in a known state | ||
// First test is always a setup test | ||
|
||
// Empty the database | ||
// 'test' is the callback in the deleteAll function in /models/users.js | ||
exports['setup'] = function(test) { | ||
users.deleteAll(function() { | ||
// At the end of all tests, need to call test.done() | ||
// Thiw will tell it that it did so the task successfully | ||
// And will then move on to the next tests | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Successful registration | ||
exports['register a user'] = function(test) { | ||
// When using test.ok(), tell it how many to expect so that it doesn't end abruptly | ||
// and claim that it's ok | ||
test.expect(1); | ||
users.create('username', 'password', function(success) { | ||
// Checks if success is true | ||
test.ok(success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Unsuccessful login | ||
exports['register a duplicate user'] = function(test) { | ||
test.expect(1); | ||
users.create('username', 'password', function(success) { | ||
test.ok(!success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Successful login | ||
exports['login a user'] = function(test) { | ||
test.expect(1); | ||
users.retrieve('username', 'password', function(success) { | ||
test.ok(success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Unsuccessful login | ||
exports['login with bad username'] = function(test) { | ||
test.expect(1); | ||
users.retrieve('badusername', 'password', function(success) { | ||
test.ok(!success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Unsuccessful login | ||
exports['login with bad password'] = function(test) { | ||
test.expect(1); | ||
users.retrieve('username', 'badpassword', function(success) { | ||
test.ok(!success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Empty the database and close the connection to database | ||
exports['cleanup'] = function(test) { | ||
users.deleteAll(function() { | ||
users.close(function() { | ||
test.done(); | ||
}); | ||
}); | ||
}; | ||
// Skyler Ng | ||
// Unit tests for the users collections | ||
|
||
// This is to get to the database code in the folder models | ||
var users = require('../../models/users'); | ||
|
||
// Before testing user collection, we want to put it in a known state | ||
// First test is always a setup test | ||
|
||
// Empty the database | ||
// 'test' is the callback in the deleteAll function in /models/users.js | ||
exports['setup'] = function(test) { | ||
users.deleteAll(function() { | ||
// At the end of all tests, need to call test.done() | ||
// Thiw will tell it that it did so the task successfully | ||
// And will then move on to the next tests | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Successful registration | ||
exports['register a user'] = function(test) { | ||
// When using test.ok(), tell it how many to expect so that it doesn't end abruptly | ||
// and claim that it's ok | ||
test.expect(1); | ||
users.create('username', 'password', function(success) { | ||
// Checks if success is true | ||
test.ok(success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Unsuccessful login | ||
exports['register a duplicate user'] = function(test) { | ||
test.expect(1); | ||
users.create('username', 'password', function(success) { | ||
test.ok(!success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Successful login | ||
exports['login a user'] = function(test) { | ||
test.expect(1); | ||
users.retrieve('username', 'password', function(success) { | ||
test.ok(success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Unsuccessful login | ||
exports['login with bad username'] = function(test) { | ||
test.expect(1); | ||
users.retrieve('badusername', 'password', function(success) { | ||
test.ok(!success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Unsuccessful login | ||
exports['login with bad password'] = function(test) { | ||
test.expect(1); | ||
users.retrieve('username', 'badpassword', function(success) { | ||
test.ok(!success); | ||
test.done(); | ||
}); | ||
}; | ||
|
||
// Empty the database and close the connection to database | ||
exports['cleanup'] = function(test) { | ||
users.deleteAll(function() { | ||
users.close(function() { | ||
test.done(); | ||
}); | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.