-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
executable file
·57 lines (49 loc) · 1.34 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//utility libraries
var crypto = require('crypto')
, _ = require('underscore')
//test boilerplate
, tu = require('./modules/test_utils')
//modules being tested
, app = require('./bootstrap')
, User = require('./modules/user');
describe('bootstrap', function() {
describe('User', function() {
var user_tester = new tu.ModelTester(User);
user_tester.testModel();
user_tester.testSchema();
describe('test instance', function() {
var user_def = {
username: 'test_user'
, password: 'test_password'
}, user = new User(user_def);
before(function(done) {
User.remove(user_def, done);
});
user_tester.testProperties(user, user_def);
var shasum = crypto.createHash('sha1');
shasum.update(user_def.password);
shasum = shasum.digest('hex');
_.extend(user_def, { password: shasum });
user_tester.testSave(user);
user_tester.testFind(user_def, user);
user_tester.testRemove(user);
user_tester.testFind(user_def, null);
user_tester.testFind({ _id: user._id }, null);
});
});
describe('routes', function() {
var app_tester = new tu.AppTester(app);
app_tester.testGet('/login', {
navbar: true
, banner: true
});
app_tester.testGet('/register', {
navbar: true
, banner: true
});
app_tester.testGet('/logout', {
type: 'text'
, redirect: '/'
});
});
});