forked from pranaypareek/sample_node_svc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
85 lines (79 loc) · 2.44 KB
/
test.js
File metadata and controls
85 lines (79 loc) · 2.44 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var db_mysql = require('./index.js').db_mysql;
var db_neo4j = require('./index.js').db_neo4j;
var chai = require("chai");
var expect = chai.expect;
var superagent = require("superagent");
var should = require("should");
/* ================= mysql =================*/
describe('MySql Database', function () {
it('should create the things table', function () {
db_mysql.schema.hasTable('things').then(function (exists) {
expect(exists).to.equal(true);
});
});
it('should save a new name', function () {
db_mysql('things')
.insert({ name: 'Johnson' })
.exec(function (err) {
expect(err).to.equal(null);
});
});
it('should retrieve that name', function () {
db_mysql('things')
.where({ name: 'Johnson' })
.select('name')
.then(function (name) {
expect(name[0].name).to.equal('Johnson');
});
});
});
/* ================= mongo =================*/
describe("Index", function () {
it("renders HTML", function (done) {
superagent.get("http://localhost:3000/")
.end(function (e, res) {
(e === null).should.equal(true);
res.text.should.equal("Hey buddy!");
done();
});
});
});
describe("Persistence", function () {
it("should create a thing", function (done) {
superagent.get("http://localhost:3000/doobie")
.end(function (e, res) {
(e === null).should.equal(true);
var response = res.body;
expect(response.created).to.equal(true);
done();
});
});
it("should retrieve a thing", function (done) {
superagent.get("http://localhost:3000/doobie")
.end(function (e, res) {
(e === null).should.equal(true);
var response = res.body;
expect(response.created).to.equal(false);
response = response.returnObj;
response.should.have.property("name", "doobie");
done();
});
});
});
/* ================= neo4j =================*/
describe('Neo4j database', function () {
it('should save a node', function () {
var node = db_neo4j.createNode({ name: 'test' });
node.save(function (err, node) {
expect(err).to.equal(null);
expect(node).to.have.property('id');
});
});
it('should retrieve a node', function () {
db_neo4j.getIndexedNodes('node_auto_index', 'name', 'test', function (nodes) {
expect(nodes).to.be.an('array');
expect(nodes.length).to.equal(1);
expect(nodes[0].name).to.equal('test');
});
});
});