/
index.test.js
49 lines (41 loc) · 1020 Bytes
/
index.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
/*!
Core Modules
*/
var vows = require('vows'),
assert = require('assert'),
mongoose = require('mongoose'),
short = require('../lib/short');
/*!
Connect to MongoDB
*/
var MONGO_DB = process.env.MONGO_DB || 'mongodb://localhost/short';
short.connect(MONGO_DB);
/*!
Vows / npm test
*/
vows.describe('general module Tests').addBatch({
'when instantiating short':{
topic:function(){
return short;
},
'short should be a function':function(topic) {
assert.isFunction(topic);
},
},
'when creating and retrieving a short url':{
topic:function() {
var URL = 'http://nodejs.org/';
short.gen(URL, this.callback);
},
'there should be no errors':function(error, shortURL){
assert.isNull(error);
},
'shortURL should be defined':function(error, shortURL){
assert.isNotNull(shortURL);
},
'and shortURL should be an object':function(error, shortURL){
assert.isObject(shortURL);
}
}
}).export(module);
/* EOF */